I've an event receiver in Sharepoint on-premise which updates a Hyperlink field with parent document set Url when a new item is added/updated.
Below is the code works good for me in SharePoint on-premise. How to perform the same step in SharePoint Online(CSOM) for Remote event receivers.
public void UpdateLink(SPItemEventProperties properties)
{
if (properties.ListItem.Folder == null && properties.ListItem.File != null)
{
string linkUrl = properties.Web.Url + "/" + properties.ListItem.ParentList.Title + "/Forms/" + getContentTypeName(properties.Web, properties.ListItem.File.ParentFolder.Item.ContentTypeId) + "/docsethomepage.aspx?List=" + properties.ListItem.ParentList.ID.ToString() + "&RootFolder=" + properties.Web.Url + "/" + properties.ListItem.ParentList.Title + "/" + properties.ListItem.File.ParentFolder.Name;
properties.ListItem["LinkName"] = linkUrl + ", " + properties.ListItem.File.ParentFolder.Item.Title;
this.EventFiringEnabled = false;
properties.ListItem.SystemUpdate();
this.EventFiringEnabled = true;
}
}
public string getContentTypeName(SPWeb web, SPContentTypeId contentTypeID)
{
SPContentTypeId ct = web.AvailableContentTypes.BestMatch(contentTypeID);
SPContentType ctt = web.AvailableContentTypes[ct];
return ctt.Name;
}
There are many properties which are not available in Client side object model like "properties.ListItem.File.ParentFolder.Item.ContentTypeId"
How to achieve this using CSOM?