.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How to update list item with same title and the name of a library?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :C#


I'm a newbie to VS and SP Development and thus asking for some help from the community.

I'd like to be able to update a list item from a workflow running on a library, the list item title is the same as the library name. 

Environment is SP2010 Ent. VS 2010.

I have imported a workflow from SPD into VS2010 and I would like to add some code using Linq to update another list.  The query will be something like:

update list item where title is equal to current item list title. 

I'm OK with the easy bit - writing the Linq code and adding the Linq context file etc.  But I don't know where I need to add the update statement.

The import has created a lot of files, the largest of which is the .rules file with about 7000 lines of code.  The placing of the code should be straight forward as I want it to be last thing to happen in the workflow depending on a current item value.

Therefore can anyone help with regards to where in the project I need to put my code?

Thanks in advance.



View Complete Post

More Related Resource Links

Concurrent update in sharepoint list item



How the concurrent for sharepoint list item are are handled.

if two or more users are working on same item. Then how sharepoint process multiple update request for particular list item.

Update SharePoint List item using UpdateListItem web service with javascript

I'm using the Custom_AddListMenuItems function in a CEWP to add a menu item to each list item to Archive that item. This is achieved by updating a choice field in the item to 'Archived'. I'm trying to do this using the web service UpdateListItem web service to update the item using Javascript, but I can not find the correct code that updates the list item. I'm using this code:     var ctx=currentCtx;     var ciid=currentItemID;     var xmlHttp=null;     if (confirm("Are you sure you want to Archive this item?"))     {         var soapRequest = '<?xml version="1.0" encoding="utf-8"?>'+             '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+             '    <soap:Body>'+             '        <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">'+         

does SPD support filtering of the mail title/body we send to a list/library?

for example, if we send a mail with the title of "%hostname% %ipaddress%" to a list. can SPD WF filter the title and get %hostname% to a new variable? the reason to ask this is i want to send a well-formated mail to sharepoint and the automatical WF can recognize the change of the list items and update the relevant columns by the filtered content from mail title or body. thanks!

Invalid data has been used to update the list Item.(List definition)

<nativehr>0x80070057</nativehr><nativestack></nativestack>Invalid data has been used to update the list item. The field you are trying to update may be read only. I have created a list definition and into that i have created lookup column when i am trying to add any item into the list then it gives me an error as above. Can anyone help me.? I made the readonly attributes to false for lookup columns.  

Item/Document permissions affect Library/List permissions

When I change the permissions on a item/document in a library/list the permissions are also changed on the library/list even though I stopped inheritance.  When I change the permissions on the library/list it also changes permissions on items/documents in that list even if inheritance is removed.

How to update selected item state in the list box by clicking a button?

I created a listbox menu to browse through content by clicking items in the listbox. I also created ‘back’ and ‘forward’ type of navigation to browse through the same content based on the browsing history. I load content into frame and accessing the browsing history with NavigationCommands.BrowseBack and BrowseForward Properties. It is working great. However, I need to indicate a selected state of the listbox item related to the content shown in the frame while browsing with Back/Forward buttons. I have a hard time binding that property. What is the correct way to bind selected state of the listitem in this case? Thank you in advance. XAML: Button <Button x:Name="NavBack" Content="" HorizontalAlignment="Left" Margin="20,0,0,0" Style="{DynamicResource BackButtonStyle}" VerticalAlignment="Top" CommandTarget="{Binding ElementName=ContentFrame}" Command="{x:Static NavigationCommands.BrowseBack}" SnapsToDevicePixels="True" IsEnabled="{Binding CanGoBack, ElementName=ContentFrame, Mode=OneWay}" > XAML: Listsbox <ListBox x:Name="Nav_ListBox" Margin="0,18,0,0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Background="#FFF2F2F2" ItemsSource="

Dynamic list item title based on date created & regional settings?

I have a list of things that doesn't *need* a title.  However, because sharepoint uses Title for links, RSS etc  I tried generating a title in an event handler.   This would work great if I wasn't basing it on a date field: public override void ItemAdding(SPItemEventProperties properties) { DateTime dt = Convert.ToDateTime(properties.AfterProperties["TestDate"]); properties.AfterProperties["Title"] = dt.ToShortDateString(); base.ItemAdding(properties); } In testing, this sets the title to "8/9/2010" when I selected 8/10/2010 in the date picker.  I figure this is because of the regional settings of my test user.  I can probably correct the title value for 'test user' but that won't fix 'test user in mongolia' who would still see two different values. So What I would like is to have the Title always display the value MyDate in the uesr's locale.  So the field needs to be dynamic not only at edit/update time, but at display time. Does anybody know if this can be accomplished, and more specifically how?

Invalid data has been used to update the list item in sharepoint 2010.

I have created a custom list definition with one lookup field <      Field ID="{865CD714-7DF6-4F65-9DBC-5FE910B10BC5}" Name="CompanyName" DisplayName="Company Name" Group="Custom contents" Description="Select Company" Type="Lookup" ShowField="CompanyName" Required="FALSE" FieldRef="CompanyName" List="Lists/LookupListDefinition-ListInstance1" ReadOnly="FALSE"></Field>   <nativehr>0x80070057</nativehr><nativestack></nativestack>Invalid data has been used to update the list item. The field you are trying to update may be read only. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. My solution is perfectly get deployed on site. I can see the list instance created on site its also appears on quicklaunch. When i am trying to add the item into the custom list using UI then i am getting the input form correctly i can see the lookup values in dropdown list but when i click on save button then its give me an error as mention above. For debugging purpose i have created the event reciver class for list item adding event. In that i have check the column status and

Multiline text field in document library and item update from Word trouble

Hi I have faced a bit of odd problem. Here is the scenario: I have document library with text columns (multiple lines of text) that are set to unlimited length. I have a workflow that runs with Word documents (.docx) that stores information in XML to this field. Everything works perfectly until document is edited in Word and saved back to document library. After Word saves my document in document library, the multiline text field is "cutted", only 7 rows of text is saved to my field. I have tried hiding my text field, making it sealed or readonly, but still Word breaks my field. Funniest thing is that when editing document in Word, this field should not have any changes (meaning that I dont show my "long text field" in document information panel back in Word). I have tried also creating event handler to handle itemupdating event in document library where I switch spweb.parserenabled property to false and in itemupdated event I switch it back on. Also I have tried to remove all line changes from XML with no luck. This XML saving to long text field works perfectly with many other places but in this one environment this does not seem to work :( I am looking forward to any suggestions what to try next. I have been wondering about using the eventhandlers and trying to "protect" my text field with some logic but that is still just a thought.   T

Workflow - automatically create discussion item using title field of of custom list item as its subj

Anyone any ideas as to how I can configure SharePoint to create a discussion item using the title of a list item. e.g. user creates list item on a custom list - SP automatically creates a Discussion thread for this list item in the discussions list. I'm guessing this can't be down OOTB . would I be looking at SPD or a coded solution ? regards, Counie

New Item Added to List/Library trigers Alert to non-AD Security Group

I am trying to implement an alert when a new item is added to a list. Idealy this alert would be sent to either a SharePoint Group or a AD Distribution Group. I do not have access/authroization to create security groups. The research I have found so far tells me that I can only add AD users and AD mail-enabled security groups through the alert GUI. My questions is first is this a valid finding? Second, if I create a custom workflow can I have the workflow triger on new item added and have it send a notification to the specified SharePoint/Distribution group? Thank you in advance for your assistance.  

Edit item title in a list on a mobile page

hello, can i edit an item title for a list on a mobile page in MOSS 2010 ? e.g i want my list items to appear as "New task StartDate:current EndDate:current" that includes three things the list title,startdate and enddate for the item. thanks

update item in list by workflow on list in other site



is it possible to update/insert item in the list of other site (other then the site on which workflow is running)?

Please advice.


task item not able to update custom list item


I have a site with NT authenticated users with READ permission only.

  • I have custom list 1 with disinherited permissions where users can add items. A column in this list captures the name of the persons Manager (person or Group). e.g item created by Person X
  • WorkFlow runs and copies the item from custom list 1 to custom list 2
  • Custom List 2 with disinherited permissions. The item continues to have Person X in the 'created by' column
  • WorkFlow runs on Custom List 2 assigning only contribute permission on Custom List 2 to the Manager entered in the item. Person X has no access to the item in Custom List 2
  • The WorkFlow has  a Collect Data From User task to be completed by the Manager. The WF runs and creates the Task in the task list. I've noticed that this item in the task list is created by Person X!
  • The Manager completes the Task successfully. Then Custom List 2 is supposed to get updated with the values the manager set in the Task.
  • The Manager has contribute permission on the item in Custom List 2, so they should be able to update the item, but the WF fails with either Access Denied, or unable to find item or some such.

Cross site lookup field value contains the parent list item id and the title field separated by ;# i

Actually we are using third party component for cross site lookup and facing the problem with cross site lookup field value. Its showing the correct value in default list view mode, but in "Edit in Datasheet" and "Export to Datasheet" view cross site lookup field value contains the parent list item id and the title field separated by ;#. I need the actual value in "Edit in Datasheet" and "Export to Datasheet" view as shown in default list value, i dont want that appended parent list item id and separated by ;#.

Is there any OutOfBox soluiton for this. Please suggest me for the same.


difference between Set Field in Current Item versus Update List Item?

Is there a technical different between Set Field in Current Item and  Update List Item if the field in the item being updated with in the same list the workflow is attached to?  It seems like there wouldn't be any difference - that you could use one or the other.  But I'm having trouble with my workflow.  It completes without error, but the field in my current list item isn't being updated (getting the value from another list in same site).
There are no mistakes; every result tells you something of value about what your are trying to accomplish.

Item update in the sharepoint list using web service with javascript



I am using below code for web services with javascript


function CreateListItem(Title)



    var soap1 = createEnvelope(Title);


    var ws = new ActiveXObject("Microsoft.XMLHTTP");    

      if(ws == null) 

       return null;





    ws.setRequestHeader("Content-Type", "text/xml; charset=utf-8");            







  function createEnvelope(Title)


     var batch;

var xmldoc;    

var ListName = 'S

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend