Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

variable value is "undefined"

alexm3
Kilo Expert

Hello,

I have a variable on a record producer named "dsn_name". At the moment, the type of the variable is wide single line text.

I also have another variable named caller_id which is a reference to sys_user table and it's mapped on the caller field. By default this value is populated with the ID of the person currently logged in the instance.

I'm trying to pull a value from the'caller_id"(distinguished_name) and populate it in the "dsn_name" field. My catalog client script looks like this:

function onChange(control, oldValue, newValue, isLoading) {

var poc = g_form.getReference('caller_id');

g_form.setValue("dsn_name", poc.distinguished_name);

  }

I'm getting 'undefined' instead of showing the distinguished_name value.

Capture.JPG

Any ideas would be me appreciated !

Thanks

Alex

14 REPLIES 14

Ravi Prasad1
Tera Guru

is that field name correct ? And also check the distinguished_name value in the table.


I'm sure the names and values are correct. I think it's a problem with the script. For example if instead of "distinuished_name" I use "location"(should show the requester's location) i'm still getting undefined.



Alex


Hi Alex,



I just tried in my instance and it is working fine with below script.



var poc = g_form.getReference('caller_id');



  g_form.setValue("short_description", poc.department);


Yes, I'm using same code in other record producers and it's working fine. The script looks correct but somehow it's not working for this item I'm currently working on