Samstag, 15. Juni 2013

vCenter Orchestrator Code Snippet: get Workflow ID

with this code snippet you can easily get the workflow token ID of the currently running workflow:

heres the script, I will explain it afterwards:
var wfToken = null;
var wfTokenURL = workflow.getAnswerUrl().url;
var strwfTokenId1 =  wfTokenURL.substring("&workflowTokenId=")+17,50000);
var strwfTokenId2 = strwfTokenId1.substring(0,"&"))

Ok, here's the explanation:
"workflow.getAnswerUrl().url" will return something like that:


The yellow part is our ID.

Important is the part before and after our ID, first I split the string in two parts and take the part after &workflowTokenId=(this are the 17 positions I add) to the end.
second thing is taking this part and split it again where the "&" is and get the first part. what you finally got is your ID.

Keine Kommentare:

Kommentar veröffentlichen