On your item
, you can call item.getOwningPublicationId()
which will return you the URI of its owning Publication, if this is the same as the Publication of which you requested the item (the first part of the TCM URI from item.getId()
), then the item is created in this Publication, else you have its parent (note, this could be a parent Publication in which the item is localized).
This and some other properties of the item will be undefined
if the item is not fully loaded, so always make sure you load the items like this for example:
var item = $models.getItem(selection.getItem(0));
if (item) {
// define onload delegate method
var onItemLoaded = function Namespace$_method$_onItemLoaded() {
$evt.removeEventHandler(item, "load", onItemLoaded);
// continue your code here
var owningPubUri = item.getOwningPublicationId();
};
// register onload event for this item
$evt.addEventHandler(item, "load", onItemLoaded);
// call to load the item
item.load(item.isLoaded(true), $const.OpenMode.VIEW);
}
Another option you have is to inspect the item XML, you can get this through item.getXml()
or item.getXmlDocument()
, but again here the item needs to be fully loaded.