how to set default value of one variable from another variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2021 02:04 AM
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 ?
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2021 03:06 AM
i even tried the same , it worked out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2021 03:20 AM
Can you mark the answer as correct so that others might find it helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2021 02:35 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2021 03:38 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader