I have been using the JSOM with SharePoint 2013 and am trying to get the content types of a list to iterate through, and am having no luck.
First, while the success handler is being reached, the oTargetCTypes variable never seems to be populated. Secondly, I occasionally get an exception thrown when a null id somewhere attempts to have the toString method called.
I see nothing wrong with this code, but if someone sees something I dont I would appreciate the assist!
function addIfPollList(listId, webId) {
this.optionListId = listId;
this.optionListTitle = listTitle;
this.optionWebId = webId;
this.clientContext = new SP.ClientContext.get_current();
this.oTargetList = clientContext.get_site().openWebById(this.optionWebId).get_lists().getById(optionListId);
this.oTargetCTypes = this.oTargetList.get_contentTypes();
this.clientContext.load(oTargetCTypes);
this.clientContext.executeQueryAsync(
Function.createDelegate(this, isPollListSuccessHandler),
Function.createDelegate(this, isPollListErrorHandler)
);
}
function isPollListSuccessHandler() {
cTypeEnumerator = this.oLists.getEnumerator();
}
function isPollListErrorHandler() {}