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

Alex,



Would you mind sharing the complete screenshot of your catalog client script form.



Thanks


Sure, np. Here it is:



fd.JPG


not sure, why it's not working it but should be whenever the form is loading.


anyways one last thing to confirm, what type of variable is dsn_name   ?


dsn_name type is single line of text at the moment. I tried making it reference( to sys_user) and it didn't work. I tried multi line text, I tried wide line text..still nothing.



Alex


Strange thing is : if I change g_form.setValue('dsn_name',poc.distinguished_name); to g_form.setValue('dsn_name',poc.phone); then it's working, it's showing the requester's phone number.



If I change to (dsn_name',poc.country) I'm getting NUL instead of the user's country. If I change to dsn_name',poc.location) I'm getting the sys_id of the location instead of the actual location.



Don't understand what is happening.



Alex