- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2020 07:33 AM
Hello Team,
I'm trying to set field values based on another field value.
I have created three variables on catalog item.
company, department & approval group. Approval group is hidden on all forms.
In company i'm having two choices Apple & Google. If I select apple based on that department values will be there in that i'm having choice based on that approval group is coming but here I need help.
Example :
If I select apple in company and service desk in department then based on that approval group is coming but when i'm trying to change field values on company or department approval group values are not getting changed. How to clear old value and add new value.
I have tried Ui policy and on change client script but both didn't worked. It's clearing the value but it's not showing new value on the filed
g_form.setValue('approval_group','');
g_form.clearValue('approval_group');
Thanks,
JRY
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2020 08:43 AM
Hi,
in this case you will require to write onchange on company and department to clear out the Approval Group when either of those 2 variables are cleared or changed
1) onchange on company -> clear approval group when company is cleared out or company is changed
2) onchange on department -> clear approval group when department is cleared out or department is changed
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020 12:12 AM
Hi,
if you are hiding that Approval Group variable in all the cases i.e. Catalog, RITM, SC Task then you can perform the step to update this variable from workflow run script
Can you share scripts on those 3 variables?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020 12:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020 01:13 AM
Hi,
Can you share complete script?
the above script doesn't help much
also use clearValue() to clear the variables; if you use setValue() it would lead to trigger onchange again
g_form.clearValue('company');
g_form.clearValue('site');
g_form.clearValue('department_folder');
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020 02:23 AM
Hi Ankur,
Please find below script which I have created but not working
if (isLoading ) {
return;
}
}
if (newValue != '') {
alert("Not empty");
g_form.setValue('company, req.company);
g_form.setValue('department', req.department);
g_form.setValue('site', req.site);
g_form.setValue('approval_group', req.approval_group);
}
else {
alert("Empty");
g_form.clearValue('company','');
g_form.clearValue('department');
g_form.clearValue('site');
g_form.clearValue('approval_group');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2020 02:31 AM
Hi,
it seems you missed some code
the function pullAttributes() is not called;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader