How to get the workflow of a change item programmatically?

Hi, I want to run the following client code from an Express ECO button event:
var innovator = new Innovator(); 

var thisItem = document.thisItem;
var id = thisItem.getID(); // id of Express ECO

// here should be the code that fetches the Workflow Process id.

var qryItem = innovator.newItem(); 
qryItem.loadAML( 
"<Item type='Workflow Process' id='/*----missing ID----*/' initial_action='get' action='do_l10n' select='state, name,related_id(name)' >" +
              "<Relationships>" +
                "<Item type='Workflow Process Activity' action='get' select='related_id'>"+
                  "<related_id>" +
                  "<Item type='Activity' action='get' select='name,related_id(name)'>" +
                    "<state condition='ne'>Pending</state>" +
                    "<Relationships>" +
                      "<Item type='Activity Assignment' action='get' select='related_id' >" +
                         "<related_id type='Identity' select='keyed_name' />" +
                      "</Item>" +
                    "</Relationships>" +
                  "</Item>" +
                  "</related_id>" +
                "</Item>" +
              "</Relationships>" +
            "</Item>"
); 
var resultItem = qryItem.apply(); 
Unfortunately I wan´t able to find the missing link between the Express ECO and the corresponding Workflow Process yet. Can you give me a hint how the two are connected? Thanks again! Angela
Parents
  • I agree with you, my query was not yet optimal. The main problem, however, was how I handled the return value. I was reading the individual query parts directly, e.g. var act = workflowProcessActivity.getItemByIndex(0).getProperty("related_id"); That did not work. But with the help of XPath I am able to read the desired values:
    var act = workflow.getItemsByXPath("//Item[@type='Activity']");
    var actID = act.getItemByIndex(0).getID();
    Thank you both for your help!
Reply
  • I agree with you, my query was not yet optimal. The main problem, however, was how I handled the return value. I was reading the individual query parts directly, e.g. var act = workflowProcessActivity.getItemByIndex(0).getProperty("related_id"); That did not work. But with the help of XPath I am able to read the desired values:
    var act = workflow.getItemsByXPath("//Item[@type='Activity']");
    var actID = act.getItemByIndex(0).getID();
    Thank you both for your help!
Children
No Data