简体   繁体   中英

What is best method to get property for the content type with the closest match using client context (CSOM)?

I'm converting Event receiver codes into Remote event receiver using SharePoint 2013 Client context.

var documentList = clientContext.Web.GetList(Constants.DocumentsListUrl);
var classifiedContentTypeId = documentList.ContentTypes.BestMatch(new
SPContentTypeId("0x0120D52000155C54BB8DF04DE78D5F78461B236DEF"));
var classifiedContentType =  
documentList.ContentTypes[classifiedContentTypeId];

Note that if the search finds two matches, the shorter ID is returned. For example, if 0x0101 is the argument, and the collection contains both 0x010109 and 0x01010901, the method returns 0x010109.

List.ContentTypes.BestMatch method is available to get closest match in SSOM. What is the right method in CSOM ? Thanks in advance

One idea is to make use of the

ContentType.Id.IsChildOf()

method and then use string methods to choose the shortest Guid ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM