My scenario: I have setup a webhook on a list and each time a new folder is created,my azure function is called(which is acting as the notification hub),where i am using the changequery to get the changes on the list.I am able to get the ObjectType and ChangeType of the event that occured in the SPList,buti am not able to figure out how to find out the ids of the newly created folder and hence do some manipulation.

2 Answers 2


I have created a step by step article in TechNet that simulates SharePoint Webhooks as Event Receivers for SharePoint Online List. You can find the implementation under the heading SharePoint Webhooks as Event Receivers in the above mentioned article.

You can get the item id as (change as ChangeItem).ItemId} . Please see the below code :

foreach (Change change in changes)
                   if (change is ChangeItem)
                       ListItem changedListItem = changedList.GetItemById((change as ChangeItem).ItemId); 

                       string emailBody = "<b>New Change in the SLA List</b> </br><table style='border: 1px solid black;'>";
                       emailBody +=   "<table style='border: 1px solid black;'><tr style='color:green;'><td>ID :"+ (change as ChangeItem).ItemId +" -- </td><td><b> Action Item : "+ changedListItem["Title"]+"</b></td><td> -- SLA : "+ changedListItem["SLADate"]+"</td></tr>";
                       emailBody +=  "</table>"; 

                       Microsoft.SharePoint.Client.Utilities.EmailProperties emailProperties = new Microsoft.SharePoint.Client.Utilities.EmailProperties();
                       emailProperties.To = new string[] { "[email protected]" };
                       emailProperties.Subject = "Attention : A new modification has occurred in the SLA List";
                       emailProperties.Body = emailBody;
                       Microsoft.SharePoint.Client.Utilities.Utility.SendEmail(SPClientContext, emailProperties);

                            log.Info($"A list item with ID : { (change as ChangeItem).ItemId} is {change.ChangeType.ToString() }" );

As you can see I have got the item ID in the Azure Logs : enter image description here


To answer your question on how to get the folder from the list item id, you can create the list item object and cast it to the folder object using ListItem.Folder property


  • at this point i get the id as you suggested,but now if i do something like getfolderByid() it ask for a guid?? any idea how to solve that Commented Aug 7, 2017 at 7:40
  • getfolderByid() will need a GUID. Instead you can get the ListItem object using the id and then get the folder object using ListItem.Folder property msdn.microsoft.com/en-us/library/… Commented Aug 7, 2017 at 7:51
  • I have updated the answer Commented Aug 7, 2017 at 7:55
  • thanks i think this will work,if you do have the code snippet ,it will help Commented Aug 7, 2017 at 9:05
  • this is my implementation but something not working,could you have a look . sharepoint.stackexchange.com/questions/223110/… Commented Aug 11, 2017 at 7:35

This works for me:

try {
    log.Info("Executing function");

    using (var ctx = await csomHelper.GetClientContext("ur url to a site"))

   ListCollection list = ctx.Web.Lists; 
    List targetlist = list.GetByTitle("Company"); 
    ChangeQuery cq = new ChangeQuery(false, false);
    cq.Item = true;
    cq.Folder = true;
    cq.File = true;

    cq.List = true;           
    cq.Add = true;           
    ChangeCollection coll = targetlist.GetChanges(cq);

     foreach (Change change in coll)
                if (change is ChangeItem)

                    ListItem changedListItem = targetlist.GetItemById((change as ChangeItem).ItemId); 
                    Folder folder=changedListItem.Folder;
                    log.Info("folder is "+folder.UniqueId);




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.