Workflow run script activity return undefined for a Reference variable

rochelleefernan
Tera Contributor

Howdy,

I am getting "undefined" result when I run script on workflow. It worked for different Variable types but not if I'm using a "Reference" variable. 

Variable set type is "Reference"

Code "current.variables.student_info.request_for"

Please help. 

Thank you
Rochellee

 

1 ACCEPTED SOLUTION

Steven Parker
Giga Sage

Looks like you are trying to dot walk to the request_for field.

If you were referencing the sys_user table for example, you could do current.variables.student_info.email and that would give you the email address off of the user record for that user.

If you are just trying to get the request_for field on the Student Info catalog item then it's just current.variables.request_for

One thing to keep in mind too is a reference field is going to return the sys_id.  You can use .getDisplayValue() to get the actual text instead of the sys_id.  Or you can dot walk like I mentioned above to get to any of the fields on the referenced record.


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

View solution in original post

4 REPLIES 4

Mike Patel
Tera Sage

what's exactly your variable name ?

current.variables.student_info.request_for

current.variables.student_info

current.variables.request_for

Narendra Kota
Mega Sage

Hi,

If your reference type variable name is student_info, then 

current.variables.student_info

is correct, but verify that when you're doing a furthermore dot-walk, then make sure that the table to which you're referencing in student_info variable does have a field named request_for or not? If not, then there is the issue, and that's the reason you're getting undefined return value for this expression. Please verify and correct it.

Hope this helps.
Mark helpful or correct based on impact.

Thanks.

Steven Parker
Giga Sage

Looks like you are trying to dot walk to the request_for field.

If you were referencing the sys_user table for example, you could do current.variables.student_info.email and that would give you the email address off of the user record for that user.

If you are just trying to get the request_for field on the Student Info catalog item then it's just current.variables.request_for

One thing to keep in mind too is a reference field is going to return the sys_id.  You can use .getDisplayValue() to get the actual text instead of the sys_id.  Or you can dot walk like I mentioned above to get to any of the fields on the referenced record.


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

Thanks that did it. So in the script itself I added .getDisplayValue

From this : current.variables.student_info.request_for

To This : current.variables.student_info.request_for.getDisplayValue()

 

Thanks everyone.

Rochellee