I have a WF that uses the following code block:
// Change the running credential: System.log("Workflow started running as: " + Server.getCredential().username); System.log("Changing to: " + newCredential.username); workflow.changeCredential(newCredential); System.log("Credential is changed."); System.log("Workflow is now running as: " + Server.getCredential().username);
Line 5 errors out with a NULL error. I get nothing descriptive at all:
2017-09-20 12:56:11.301] [E] Workflow execution stack:
***
item: 'Credential Test/item1', state: 'failed', business state: 'null', exception: 'null'
workflow: 'Credential Test' (670d0b4c-b6d8-46c8-8471-6853dbf08413)
| 'attribute': name=errorCode type=string value=
| 'input': name=newCredential type=Credential value=newUser:newPassword123
| 'no outputs'
*** End of execution stack.
I would just use the "Change Credential" built-in action, but as you see above the credential you pass into it gets exposed in plain text to any user running the workflow. My workaround was to create a new credential in the script and use workflow.changeCredential() to change to it.
For some reason, I can't call workflow.changeCredential though. The "CHange Credential" action DOES work, and as far as I can see, it uses the same javascript code.
Does anyone know how to change the running credential with code?
I'm running VRO 7.3.0.