Christopher_Mal
ServiceNow Employee
ServiceNow Employee

Today's post is a short one.   I recently ran into an issue where I was creating a custom workflow activity and wanting to use the dynamic variable syntax to submit data on the fly - when the workflow runs.   Normally to do this in a workflow you would use the dollar sign bracket syntax ${variableName}, but for some reason the actual string ${variableName} was getting submitted and not replaced with my variable value.

Lucky for me I have friends in high places.   I reached out to one of our amazing developers, @Jesse Schulman and asked him what was going on.   What I learned is that a workflow activity uses a base class function call that calls into the JSUtils.strEval function to replace those dynamic variables with the variable values at runtime.

You don't really have to remember all of that.   The important thing is that you dereference the variable in the activity using this syntax:

this.js(activity.vars.variableName)

That is it.   This will make sure that you can use dynamic variables in a custom workflow activity field.   Cheers.

1 Comment