Unable to get the current item properties inside my Remote Event Receiver. I got the After and Before only
-
08-02-2021 - |
Question
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:
So when updating an item, I should get the before, current and after properties for the item, is this correct?
Solution
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();
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange