After newly creating a content type via JSOM, I'm getting the following error when calling contentType.update()
or context.load(contentType)
:
The object is not associated with an object identity or the object identity is invalid.
Can you explain what this means, and how to avoid it?
I know (by inspecting the source of sp.js
) this is happening because contentType.get_path().$d_0
is false
, but I don't know what that means, or how to make it true again.
// excerpt from SP.ClientQueryInternal, where the error is thrown
// a is the content type in this case
if (!a.get_path() || !a.get_path().$d_0)
throw Error.create(SP.ResResources.getString("NoObjectPathAssociatedWithObject"));
However, I've tracked when that value becomes false.
Here's how I'm creating the content type. This is where the $d_0
property becomes false
.
// Create the content type
ctInfo = new SP.ContentTypeCreationInformation()
// Set up the info
// ...
contentType = contentTypes.add(ctInfo);
contentType.update()
context.load(contentTypes)
context.load(contentType) // This works, although it is superfluous
// contentType.get_path().$d_0 is true at this point
context.executeQueryAsync(successHandler, failureHandler)
// contentType.get_path().$d_0 is now false; this is before the success handler is called!
context.load(contentType) // Fails here (although it is superfluous at this point)
context.executeQueryAsync()
After successHandler
returns, $d_0
is still false
, and contentType.update()
or context.load(contentType)
still fails (e.g. while trying to add site columns to contentType
.
getByTitle
or such. I've been using the reference returned bycontentTypes.add
. This has worked in the past, and I'm not sure what's different now. – jpaugh Sep 12 '17 at 18:35