
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 07:10 AM
Hi Everyone,
I got a requirement to add the state choice and display it based on the change of a field called "pmo task type". As a default in the state field all these choices will be visible (new,assigned,work in progress,release planned ,development,sit uat, scenarios complete, sit complete ,resolved,closed,closed not need, cancelled).There are 6 choices in pmo task type field (rom,feedback,gap analysis,requirements,code enhancement,test recreation).so its like if the pmo task type changes to code enhancement then the state field should be displayed only with these choices (new,assigned,release planned,development,sit,uat,closed,closed not needed,cancelled) and if the pmo task type is test recreation then the state should contain only these values (new,assigned,scenarios complete,sit complete,resolved,closed,closed not needed,cancelled) and for remaining all other pmo task type the state should be (new,assigned,work in progress,resolved,closed, closed not needed,cancelled).....I tried to achieve this with onchange client scripts but its working as excepted ....i tried multiple different way to code still no luck....
plz anyone help me with
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 07:19 AM
Hi Subhiksha,
You can achieve this with below Onchange client script:
if(g_form.getValue('pmo_task')=='A'){ //pass the correct field name and value
g_form.clearOption('state'); // to clear all the obtions and then start adding.
g_form.addOption('state','Value of choice','Label of choice');
g_form.addOption('state','value of choice 2','label of choice 2');
.... and so on
}
else if(g_form.getValue('pmo_task')=='B'){
g_form.clearOption('state');
g_form.addOption('state','Value','Lable');
..... so on
}
else{
g_form.clearOption('state');
// Now start additing option as shown above.
}
Please mark this as correct and helpful if it resolved the query or lead you in right direction.
Thanks,
Mohit Kaushik
Community Rising Star 2022
Mohit Kaushik
ServiceNow MVP (2023-2025)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 07:16 AM
What code did you try?
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2022 07:19 AM
Hi Subhiksha,
You can achieve this with below Onchange client script:
if(g_form.getValue('pmo_task')=='A'){ //pass the correct field name and value
g_form.clearOption('state'); // to clear all the obtions and then start adding.
g_form.addOption('state','Value of choice','Label of choice');
g_form.addOption('state','value of choice 2','label of choice 2');
.... and so on
}
else if(g_form.getValue('pmo_task')=='B'){
g_form.clearOption('state');
g_form.addOption('state','Value','Lable');
..... so on
}
else{
g_form.clearOption('state');
// Now start additing option as shown above.
}
Please mark this as correct and helpful if it resolved the query or lead you in right direction.
Thanks,
Mohit Kaushik
Community Rising Star 2022
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2022 04:51 AM
Hi Subhiksha,
I saw you have marked my answer as helpful. If your query is resolved, then I would request you to mark the answer as correct so that this thread can be closed and other people can get help from the same.
Thanks,
Mohit Kaushik
Community Rising Star 2022
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2025 05:40 PM