seems like a simple task, but I'm having issues figuring it out. I'd like to pull the username out as a string within a workflow to use within a field. I can see the logic that's used to do the same sort of thing within the built in "Create Snapshot of resource pool VMs" workflow, but in that case it is appending the date:
var date = new Date();
snapName = snapNamePrefix + " " + date.toGMTString();
I attempted to search the API browser for username, came up with credential.username
Then attempted this:
var date = new Date();
var strUsername = new credential.username();
snapName = snapNamePrefix + " " + date.toGMTSTring() + " " + strUsername
So not sure how to approach this (I tried it w/out the new method in front as well). While I've got your attention, is there something akin to an immediate pane, where I can see what a simple expression would return, or am I forced to save and close the workflow, then run it?
Thanks for looking!
Dave
Hi!
Try to use
var currentUserName = Server.getCredential().username;
to figure out the currently logged in user.
If you want to get the user who started the Workflow, you can take it from the workflowToken:
var username = workflow.runningUserName;
See the original example on vcoteam.info:
http://www.vcoteam.info/learn-vco/code-snippets-cancel-one-of-your-running-workflows.html
and some background information about the WorkflowTokens:
http://www.vcoteam.info/learn-vco/how-to-retrieve-workflow-execution-details.html
http://www.vcoportal.de/2012/03/workflow-reflection/
Cheers,
Joerg
Hi!
Try to use
var currentUserName = Server.getCredential().username;
to figure out the currently logged in user.
If you want to get the user who started the Workflow, you can take it from the workflowToken:
var username = workflow.runningUserName;
See the original example on vcoteam.info:
http://www.vcoteam.info/learn-vco/code-snippets-cancel-one-of-your-running-workflows.html
and some background information about the WorkflowTokens:
http://www.vcoteam.info/learn-vco/how-to-retrieve-workflow-execution-details.html
http://www.vcoportal.de/2012/03/workflow-reflection/
Cheers,
Joerg
Oh, and for your second question: there is no kind of "script debugger" in the vCO Client. So yes, you are forced to "Save and Close and Play" the workflow...:smileyplain:
Thanks for the quick response!
Server.credential(). worked nicely, but
workflow.runningusername returned Undefined in my test. Something I need to declare / define earlier in the workflow perhaps?
Better than error out, though . I've clearly got some learning to do. Pretty nice how one can watch the logic flow in the workflow as it runs.
be aware: JavaScript is Case-Sensitive! the attribute of the workflowToken is named runningUserName....
Cheers, joerg
"Oh, and for your second question: there is no kind of "script debugger" in the vCO Client. So yes, you are forced to "Save and Close and Play" the workflow...:smileyplain:"
Is this something we will see in the near term? It's the only IDE I've used that doesn't offer it...thanks.
A debugger has been considered many times but always lower priority than everything new in the product.
This year is the same : expect significant upcoming end user experience improvements but no debugger yet.
Christophe.
Thanks Chris. Although I'm sure it would present a great deal of effort, I would strongly encourage the product folks to consider it. In an enterprise organization like ours it would be a huge benefit.