how to set default value of one variable from another variable?

rahul67
Kilo Expert

first variable : list of departments 

second variable : list of users but the default value should be the head of the department selected in the first variable.

how to achieve this ?

8 REPLIES 8

i even tried the same , it worked out

Can you mark the answer as correct so that others might find it helpful.

Community Alums
Not applicable

Hi,

You can write an onChange client script.

Here is a sample script , just replace the field names and values as per your requirements:

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

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

}

function doAlert(caller) { //reference is passed into callback as first arguments

g_form.setValue('v_supervisor_emp_id',caller.u_supervisor_id);

}

 

Please mark my answer as Correct & Helpful, if applicable.

Thanks

Sandeep

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Since your 2nd variable is dependent on 1st variable are you setting some default value in 1st variable?

then only it makes sense setting default value for 2nd variable

Regards
Ankur

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