P.Muralikrishna
P.Muralikrishna

Reputation: 1289

How to get the metadata of a page(minor version) in Tridion for Context Menu Item?

I am using SDL Tridion 2011 SP1 version.

But as workflow is enabled in the system, whenever I copy a page from one SG to another SG and clicking the save button explicitly will trigger the Workflow.

Until the workflow is completed I am unable to get the modified metadata in the Context menu JS code (Event System will update the modified the current page path in metadata).

Suspected reason : Unable to fetch the metadata for minor version.

Current code :

var itemId = selection.getItem(0);
var item = $models.getItem(itemId);
var contentXml = item.getStaticXmlDocument();
var currentPath = $xml.getInnerText(contentXml, "//*[local-name()='current_path']");

Please suggest me how to handle the scenario in Java script. Early response is appreciated. Thanks in Advance.

Upvotes: 3

Views: 313

Answers (2)

Peter Kjaer
Peter Kjaer

Reputation: 4316

It looks like you are assuming that the item has been loaded. That is not going to be the case very often.

You should check the isLoaded() method and if it returns false, call the load() method with a callback. Then do your check for processing in the callback, since items are loaded asynchronously.

Upvotes: 2

Arjen Stobbe
Arjen Stobbe

Reputation: 1684

Can you change the metadata on a different event? E.g. on the Copy or Move event?

See Tridion.ContentManager.Extensibility.Events.CopyEventArgs or MoveEventArgs.

Upvotes: 0

Related Questions