0

I am updating RefCreated column in sharepoint list when new item is getting created. Problem is if 7 items are already there and 8th item is added by user all RefCreated field of items will get updated by that user. I want to update only current newly added item. I am using below code.

uploadFile = uploadFile.FinishUpload(uploadId, fileoffset, s);
ListItemCollection items = docs.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(items);
User currentUser = ctx.Web.CurrentUser;
ctx.Load(currentUser);
ctx.ExecuteQuery();
Logger.Info("valueD" + currentUser);
foreach (var item in items)
{                                     
     item["RefCreated"] = toaddress;
     //item["ReferenceCreated"] = toaddress;

     item.Update();
     Logger.Info("valueD");
}
ctx.ExecuteQuery();
7
  • 1
    From the code you posted it seems that you are updating for all items using for each loop. You will need to write code in such a way that it will get only created item and do the updation for that item only
    – P S
    Commented Feb 12, 2019 at 10:11
  • yes, can you help me with that
    – Brishal
    Commented Feb 12, 2019 at 10:12
  • Hi Brishal, you will need to add more detail to your question and if possible your full code.
    – P S
    Commented Feb 12, 2019 at 10:16
  • I have updated the code, we are uploading a new file every time code run and updating RefCreated field. but Refcreated field is getting updated for other previously added items as well.
    – Brishal
    Commented Feb 12, 2019 at 10:25
  • Hi Brishal, google search "upload file with metadata using CSOM". You will get so many examples.
    – P S
    Commented Feb 12, 2019 at 10:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.