0

I created an ItemUpdating RER and I want to get the value of a column then transfer it to another column, here is my code

public void ProcessOneWayEvent(SPRemoteEventProperties properties)
        {
            // On Item Added event, the list item creation executes
            if (properties.EventType == SPRemoteEventType.ItemUpdated)
            {
                using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
                {
                    if (clientContext != null)
                    {
                        try
                        {


                            List list = clientContext.Web.Lists.GetByTitle(properties.ItemEventProperties.ListTitle);
                            ListItem listItem = list.GetItemById(properties.ItemEventProperties.ListItemId);

                            clientContext.Load(listItem);
                            clientContext.ExecuteQuery();

                            string rawMetadata = properties.ItemEventProperties.AfterProperties["Source_x0020_Metadata"].ToString();                               


                            listItem["Console"] = rawMetadata ;
                            listItem.Update();
                            clientContext.ExecuteQuery();
                        }
                        catch (Exception ex) { }
                    }
                }
            }
        }
0

Try this:

public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
    SPRemoteEventResult result = new SPRemoteEventResult();
    if (properties.EventType == SPRemoteEventType.ItemUpdating)
    {
        result.ChangedItemProperties.Add("<column>", "<new value>");
        result.Status = SPRemoteEventServiceStatus.Continue;
    }
    return result;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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