I have written a simple code on VS 2015 to handle ItemAdded EventReceiver but it won't fire as expected.
public void ProcessOneWayEvent(SPRemoteEventProperties properties)
{
try
{
using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if (clientContext != null)
{
switch (properties.EventType)
{
case (SPRemoteEventType.ItemAdded):
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
List list = clientContext.Web.GetList("https://learn91.sharepoint.com/sites/Demo/Lists/List1");
clientContext.Load(list);
clientContext.ExecuteQuery();
CamlQuery query = new CamlQuery();
query.ViewXml = @"<OrderBy><FieldRef Name='ID' Ascending='FALSE'/></OrderBy>";
ListItemCollection items = list.GetItems(query);
clientContext.Load(items);
clientContext.ExecuteQuery();
foreach (ListItem item in items)
{
item["Description"] = "Updated After Event Trigger";
clientContext.Load(item);
clientContext.ExecuteQuery();
}
break;
}
}
}
}
catch (Exception ex)
{
string ErrorMessage = ex.Message;
}
}
Can anyone help what could be issue?Thanks in advance!!