Dot walked field as a catalog item

Anish Reghu
Kilo Sage
Kilo Sage

Dear all,

How to display a catalog item variable that auto-populates field value based on another field input? I am referring to dot walking here.

E.g. Catalog item - X has two variables: User and Manager.

Requirement: While the requester selects User - a reference to sys_user, the Manager variable should auto-populate the value from the sys_user table for the selected user. (Just as it happens on the form while dot walking)

I doubt if this is possible, because another thread was mentioning this as not possible. Is there any workaround? If yes, please detail with script, if possible.

1 ACCEPTED SOLUTION

Tanushree Doiph
Mega Guru

Please try with the script below.

 

 

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

 

    var caller = g_form.getReference('user', PopulateManager); // PopulateManager is our callback function

 

}

 

function PopulateManager(user) { //reference is passed into callback as first arguments

 

  g_form.setValue('manager',user.manager);

 

 

}

 

 

 

Please change the variable name that you have exactly in your catalog form.

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

You cannot bring dot walked field on catalog form from reference variable.

So you would require to create another variable to hold the manager

How to auto-populate?

1) use g_form.getReference() with callback to get manager and then set

OR

2) use GlideAjax and script include approach

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Tanushree Doiph
Mega Guru

Please try with the script below.

 

 

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

 

    var caller = g_form.getReference('user', PopulateManager); // PopulateManager is our callback function

 

}

 

function PopulateManager(user) { //reference is passed into callback as first arguments

 

  g_form.setValue('manager',user.manager);

 

 

}

 

 

 

Please change the variable name that you have exactly in your catalog form.

For someone new and looking into this:

* Create a catalog client script on the catalog item where you want the value to be auto-populated.

find_real_file.png

Above is my solution.