current.variables.<variable name>.getDisplayValue() returning a string of nonsense

KevPR21
Kilo Guru

I have a workflow that has a run script activity that sets the RITMs short description like this:

current.short_description = current.cat_item.name + " - " + current.variables.<variableA>.getDisplayValue();

This has been working correctly until now. I don't know if it's because of the London upgrade but now my RITMs short description's current.variables.<fieldA>.getDisplayValue() is displaying the following string:

<variableB>:<sys_id>,variableA:<sys_id>,<variableC>:<selected value in form>

[variableB is a reference field as well in my form. Both variableB and variableC are part of the same variable set as variableA]

I put the following lines to see what was being printed:

gs.info("current.variables.<variableA>: " + current.variables.<variableA>);
gs.info("current.variables.<variableA>.getDisplayValue() " + current.variables.<variableA>.getDisplayValue());

The output of both lines is the same nonsense I mentioned above. This doesn't make sense because 

current.variables.<variableA> should output the selected record's sys_id since variableA is a reference field. 

current.variables.<variableA>.getDisplayValue() should output the selected record's actual display name and yet they are both displaying the same string.

1 ACCEPTED SOLUTION

KevPR21
Kilo Guru

The issue was that <variableA> name was the same as the name of the variable set it was on.

they were both called computer_name so it was setting things in the wrong way. I changed the variable set name to something else and it got fixed.

View solution in original post

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

Can you also try current.variables.<variable>.name.

If it is a variable set, also try current.variable_pool.<variable>.getDisplayValue()


Please mark this response as correct or helpful if it assisted you with your question.

Thanks for your reply,

 

With current.variables.<variable>.name I get undefined.

With current.variable_pool.<variable>.getDisplayValue() I get the same string as earlier.

 

Any ideas?

Brent Sutton
Mega Sage

Hi Kev,

Can you please try the following for me:

current.variables["variableA"].getName();

I was reading in ServiceNow docs about Workflow catalog variables and there may have been some changes introduced in London.

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

KevPR21
Kilo Guru

The issue was that <variableA> name was the same as the name of the variable set it was on.

they were both called computer_name so it was setting things in the wrong way. I changed the variable set name to something else and it got fixed.