Forum Discussion
angela
8 years agoCatalyst II
Hi Mahmoud,
thanks for your example! I was able to read the ID with your code instantly. I've always searched inside the WorkflowProcess ItemType for the missing link, but I didn´t notice the Workflow ItemType.
Here it is even described with an "you cannot overlook it" image - which of course I have overlooked:
community.aras.com/.../
But maybe someone can help me here: I want to avoid the use of multible queries for getting all needed information. So integrated the Workflow query into my regular code. Querying the Workflow Process id now works, but I cannot read my other values anymore:
var innovator = new Innovator();
var thisItem = document.thisItem;
var id = thisItem.getID(); // id of CM item
var type = thisItem.GetType(); // Type of CM item, e.g. Express ECO
var workflow = innovator.newItem("Workflow","get");
workflow.setProperty("source_id", id);
// workflow.setProperty("source_type", "CBA93BEFFB4F499CAF122CB79E204983"); // Express ECO
workflow.setAttribute("select", "state, name, related_id(name)");
var workflowProcess = workflow.createRelatedItem("Workflow Process","get");
workflowProcess.setAttribute("select", "name, id");
var workflowProcessActivity = workflowProcess.createRelationship("Workflow Process Activity","get");
workflowProcessActivity.setAttribute("select", "related_id");
var activity = workflowProcessActivity.createRelatedItem("Activity", "get");
activity.setPropertyCondition("state", "ne");
activity.setProperty("state", "Pending");
activity.setAttribute("select", "name,related_id(name)");
var activityAssignment = activity.createRelationship("Activity Assignment", "get");
activityAssignment.setAttribute("select", "id, related_id");
var identity = activityAssignment.createRelatedItem("Identity", "get");
identity.setAttribute("select", "keyed_name");
workflow = workflow.apply();
var wfpID = workflow.getItemByIndex(0).getProperty("related_id"); // Workflow Process ID - works!
var act = workflowProcessActivity.getItemByIndex(0).getProperty("related_id"); // don´t work, returns undefined
alert(wfpID + " " + act);
What could be missing?
(I converted the "staircase" AML query into a flat hierarchy. For me this structure is easier to use, but that's a personal habit.)