Hot answers tagged

19

The two items are not really related. AllowUnsafeUpdates will allow changes to the content database happen on a GET request instead of a POST request. This is a very bad idea. It is very trivial to write a script to perform 1000s of GET requests per minute, which would update your content database with duplicates. The actual use cases for AllowUnSafeUpdates ...


7

Update list item using powershell - $SPAssignment = Start-SPAssignment $SPWeb = Get-SPWeb http://SP -AssignmentCollection $spAssignment Next step is to get the list: $SPList = $SPWeb.Lists["Announcements"] When we have located the list we can retrieve the item. The quickest way is to use the GetItemByID() method: $SPItem = $SPList.GetItemById("1") ...


7

If you are updating a list item more than once in succession, after the first update the list item (oListItem in your case) object will have become stale, and the server will reject the update. SharePoint uses a hidden field called owshiddenversion, which gets downloaded along with your CSOM object, to determine which version you are editing. When you send ...


7

You use SPSecurity.RunWithElevatedPrivileges when you have a piece of code which requires higher privileges than currently logged in user. For example, your code wants to check if current user belongs to "Approvers" group and Approvers group is configured such that only members of Approvers group can see the membership. You will need ...


6

Try the following script: $web = Get-SPWeb http://YourServer/ListLocation $list = $web.Lists["TheList"] foreach ($item in $list.Items) { if( $list.Fields.ContainsField("ddlTest") -eq $true) { $item["Number"] = Get-Random -Min 0 -Max 100; $item.Update(); } }


6

I anticipate that your root list has the same event receiver assigned to it, and that causes the recursion. The problem, of course, may be not so obvious, but anyway, to prevent event receiver to fire several times, there is a common practice in SharePoint: just use DisableEventFiring and EnableEventFiring methods. internal void ...


5

The two are totally different things as explained here: AllowUnsafeUpdates vs RunWithElevatedPrivileges http://rameshsps2010.blogspot.co.uk/2011/06/allowunsafeupdates-vs.html AllowUnsafeUpdates Gets or sets a Boolean value that specifies whether to allow updates to the contents database as a result of a GET request or without requiring a security ...


5

If you only use this for display purposes, why not use a different approach which does not require you to do updates on the list item at all.... Create the site column in a sandboxed solution. Your column stores the Due date. Create a javascript file to deploy somewhere to your site, e.g. /Documents/duedate.js Configure the JSLink property in the site ...


5

I have a list called rohit_list1 on which i am updating title for all the items with ID greater than 15. You Write your own CAML query to get ID's. Design : <input type="button" value="updateMultipleListItems" onclick="getItemsToBeUpdated()" /> JSOM Code : <script type="text/javascript"> var collListItemToBeUpdated = ""; var ...


4

Change NULL to null. I tried the following - first test resulted in a 400 Bad Request error, the second one worked fine. {'__metadata': { 'type': 'SP.Data.TasksListItem' },'StartDate': NULL} {'__metadata': { 'type': 'SP.Data.TasksListItem' },'StartDate': null}


4

Not sure I would use PowerShell for this. Why not use Business Connectivity Service (SP2010) or Business Data Catalog (SP2007) for this? If you need to move data redundantly into a list in SharePoint with certain intervals another option would be SQL Integration Services.


3

Here is the final version. I had to use SP Manager to get the guid of the term set. I am sure I can add more logic to PS script and look for actual term. But for now this works... I updated the code with the working code in the original post and below. $webUrl = "http://intranet.nissan.usa/sites/sentra" $web = Get-SPWeb $webUrl $list = $web.Lists["sales"] ...


3

The problem is that you are using a filepath that is URL encoded (the %20 should be a space): <Batch OnError="Continue"> <Method ID="1" Cmd="Update"> <Field Name="ID" /> <Field Name="FileRef">http://sharepoint:32667/personal/user/Shared Documents/EmailMessage.msg</Field> <Field ...


3

You have to "roll your own check". User GetListItems to see if there is an existing item and then conditionally either add a new item or update the existing one.


3

I still think that it should be timerJob; you can add "Processing Status" field to master list to track job progress and use tight schedule, but it will definitely work better than attempt to use async event receiver. just my opinion


3

OK, SO I think I solved my problem. I actually had two things going on here: 1) A WCF connection propagates metadata updates on check-in to another web application (ASP.NET). The field I was constantly getting messages about IS required on that site. Wouldn't expect anyone on here to figure that out. I made the field required in SharePoint and set ...


3

This turned out to be unrelated to the XML or privileges. The URL I used to hit lists.asmx on the production site was pointing to the root of the site instead of to the web where my list is. So I was using http://mysite/_vti_bin/lists.asmx when I should have used http://mysite/web1/web2/_vti_bin/lists.asmx


3

What is happening is that your event receiver is kicking in before your PowerShell is done, and modifying it on a different thread before your PowerShell update occurs. When SharePoint hits your update statement, it sees that the item in the database is no longer the same as the one it's trying to update. I've got 3 different approaches: Set all of your ...


3

First thing first, Yes you will have to call listItem.Update() reason is because in itemAdded event Item has been added to list already and now you are about to update it. Second, as Paul said you setting item level permissions can be nightmare as they actually effect page's performance while loading it. Third, you might would like to look at this article, ...


3

Since you don't need to use the SPServices library, you can accomplish this via REST and the moveTo() method. The following should work: var url = "/_api/Web/Lists/getByTitle('My List Name')/Items", qs = "?$filter=Attachments eq 1&$select=ID,Author/Title,*&$expand=Author"; $.ajax( { url : siteUrl + url + qs, type : 'GET', headers : { ...


3

here is powershell script to list all properties and then how to change them. # Load SharePoint library [system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") # Connect to the site collection http://SP2010 and store the object in the $site variable $site = New-Object Microsoft.SharePoint.SPSite("http://SP2010") # Connect to the root ...


3

Update this <Value Type='Text'>" + objdocument.Title + "</Value>


3

Explanation Based on your affirmative response to my comment, I've gone ahead and wrote this using the JSOM API. The script works by disabling the ReadOnly property on the RichMessage field, updating the values on your target item, and re-enabling the ReadOnly field. Up until now, this is the only working strategy I've found to change read-only fields from ...


2

Because you do not Change the value in the field, you just Change the value in your variable. you have to item[fieldID] = "";


2

Avoid using SPContext inside receiver. SPContext doesn't exist in a feature receiver. Instead use the Properties object as it includes a reference to the site or web use following public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; using (SPSite site = new ...


2

In order to modify/update the Author field using the client object model, you need to make sure to Load the Source Item Load the User Object with Source Context Ensure the User Object in the Destination Context Insert the User Object in the Destination Item Update the Destination Item Please find below the pseudo code. sourceCtx.Load(sourceItem); ...


2

You can use workflow to edit project numbers of the items in the People list when creating an item in the Projects list. But when editing item in the Projects, workflow cannot get the original data of this item, so we cannot plus / minus project number of the item in the People List based on the project item. We can only update People list when creating an ...


2

you are providing listID instead of List Name and could be the source of the issue listName: "{17C2EC72-7229-445D-87A1-38AE11051906}", //give list name here


2

Try this clntCntxt.Load(newFile); clntCntxt.ExecuteQuery(); //check out to make sure not to create multiple versions newFile.CheckOut(); ListItem newFileItem = newFile.ListItemAllFields; newFileItem["MyComments"] = "test"; newFileItem.Update(); // use OverwriteCheckIn type to make sure not to create multiple versions newFile.CheckIn(string.Empty, ...


2

Improving the code suggested by @wjervis, you can change the header of ajax request to: headers: {          'accept': 'application/json;odata=verbose'      } This way it will return a Json response, that I think it is more easy to handle. You can get the length of the response by doing: data.d.results.length Additionally, you can put one more "expand" ...



Only top voted, non community-wiki answers of a minimum length are eligible