- 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-03-2020 07:38 AM
Hi,
I'm sorry...I'm a bit confused by your question, but you would use:
g_form.clearValue('approval_group'); to clear the value from the approval_group field (you'd want to double-check the field name).
If you're trying to set a new value, then you would use:
g_form.setValue('approval_group','sys_id_of_group'); so this is assuming the approval_group field is spelled correctly AND is a reference field to the group table. To set a value, you'd want to use the sys_id of the group here.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 09:41 PM
Hi Allen,
Sorry for confusing you, i will give you example.
In my catalog item there are four variables which are dependent on each other
Variables Choices
- Company - Newyork/Sydeny
- Department - SD/Network/Backup/Storage
- Site - Mexico/Brussells/Hongkong/Adelide
- Approval Group - refrence variable for table "sys_user_group"(This field values are depend on Company & Department (or) Comapny & Site) because I have used data lookups in that have set Assignmnet lookups based on company & department/ Comapny & Site respective assignment group should set.
Approval Group variable is hidden on all views(RITM/Task/Catalog item) so, we can't change once request is submitted.
Here i need help which i have tried using UI policy/OnChange Client Script but it's clearing the value on approval group but I need when I select company & department or site variable choices then approval group variable value is set but when I change company or department or site values then it's showing still blank. I need to value set when i change values on company or department or site automatically when i change previous value on any of the field.
Thanks,
JRY
- 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-03-2020 08:31 PM
Hi Ankur,
I have tried on both but it's getting field cleared but when i'm selecting new value then it's still showing blank.
Thanks,
JRY