The CreatorCon Call for Content is officially open! Get started here.

Workflow scratchpad on subflow

matt_a
Kilo Guru

Hi, I have a workflow that ultimately creates an AD account and populates with some standard user information.

2 of the AD attributes are derived from reference fields on the user record in ServiceNow.

These are location and Cost Center.

In my workflow, I add the fields to the scratchpad:

workflow.scratchpad.cost_center = current.variables.cost_center.getDisplayValue();
workflow.scratchpad.location = current.variables.location.getDisplayValue();

The workflow then adds these values as inputs into a subflow:

find_real_file.png

In the subflow, I return these values to a new scratchpad:

if (workflow.inputs.u_cost_center.toString() != '') {
	workflow.scratchpad.cost_center = workflow.inputs.cost_center.toString();
}else{
	workflow.scratchpad.cost_center = not_received;
}

if (workflow.inputs.u_location.toString() != '') {
	workflow.scratchpad.location = workflow.inputs.location.toString();
}else{
	workflow.scratchpad.location = not_received;
}

However, rather than the subflows scratchpad being populated with the displayValue of the 2 fields, its populating it with the sys_id of the values even though the original scratchpad contained the display value.

Would anyone know why this is and how I can rectify it?

 

1 ACCEPTED SOLUTION

Hi,

So to assist, I created a catalog item with a reference field, had a parent flow that set the display value to a workflow scratchpad variable, passed it to a subflow, and then checked the value in the subflow and yea...a sys_id is coming across instead.

I tried several different things in the parent flow:

  • Dot-walking to the "name" of the location
  • Using getDisplayValue()
  • Setting one scratchpad variable to the name, then passing that to a second variable and using that second variable as what is passed to the subflow

And in all of those...the sys_id still came across, haha.

So, with that said, you'll have to use a run script activity, for example, and GlideRecord to take that sys_id to retrieve the display/name value from the relevant within the subflow, and then use it that way.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

5 REPLIES 5

Hi @matt.a 

You're welcome and thanks for posting this as it brought upon a scenario I dug in on too.

If any reply was Helpful, please mark it as Helpful as well.

Take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!