0

I have the following code inside my remote event receiver:

  public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
        {
          var currenttitle = properties.ItemEventProperties.AfterProperties["Title"];

But inside the properties.ItemEventProperties it does not have a method to retrieve the current properties, where i only got the Before and After properties as follow:

enter image description here

So when updating an item, I should get the before, current and after properties for the item, is this correct?

1 Answer 1

1

AFAIK, properties.ItemEventProperties doesn't have the current item. but it has the listid and itemid, so using that we can fetch it from the list and use it.

using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
    if(clientContext != null)
    {
        List requestList = clientContext.Web.Lists.GetById(properties.ItemEventProperties.ListId);
        ListItem item = requestList.GetItemById(properties.ItemEventProperties.ListItemId);
        clientContext.Load(item);
        clientContext.ExecuteQuery();
        item["Your column Name"] //this will have the current item value
        item.Update();
        clientContext.ExecuteQuery();                        
    }
}
2
  • yes i know i can get the item by id, but this mean extra request to the server, i was trying to find a way to get the properties directly... but seems it is not available..
    – John John
    Jan 28, 2020 at 12:35
  • 1
    yes, as per the Microsoft documentation, docs.microsoft.com/en-us/previous-versions/office/…, SPRemoteEventProperties.ItemEventProperties doesn't have the current item Jan 28, 2020 at 12:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.