0

Hello SPointers,

I have recently started to work on Remote Hosted App and I created a Remote Event receiver on ItemAdded event but its not triggering can anyone Please help me.

Here is my code…..

————————————

  public void ProcessOneWayEvent(SPRemoteEventProperties properties)
        {
            using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
            {
                if (clientContext != null)
                {
                    if (properties.EventType == SPRemoteEventType.ItemAdded)
                    {
                        AddListItem(clientContext, properties);
                    }

                }
            }
        }

        public static void AddListItem(ClientContext clientContext, SPRemoteEventProperties properties)
        {
            try
            {
                List Olist = clientContext.Web.Lists.GetByTitle(properties.ItemEventProperties.ListTitle);
                 ListItem listItem = Olist.AddItem(new ListItemCreationInformation());
                listItem[“Title”] = “TestItem” + properties.ItemEventProperties.ListItemId;
                listItem[“DateTime”] = System.DateTime.Now;
                listItem[“Action”] = properties.EventType.ToString();
                listItem.Update();
                clientContext.ExecuteQuery();
            }
            catch (Exception e)
            {
            }
        }

(Visited 98 times, 1 visits today)
Add a Comment