add option in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 09:49 PM
On load of sc_req_item i need to add one option in the state field which is already available in the choice list and is disabled for now for some reason so will the below code will work for adding it back ?
g_form.addOption('state','104');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 11:12 PM
Hi @jobin1 ,
addOption accepts three arguments
g_form.addOption('state', '104', 'Nameofthestate');
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 11:56 PM - edited 12-02-2022 12:18 AM
it's working but once the state is saved with that value its again immediately updates to none why so?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 11:18 PM
@jobin1 You can add the below script, which includes the choice label as well
g_form.addOption('state',104,'<CHOICE LABEL HERE>');
BTW if the field is disabled you can never use that option which you added from script.
So you need to make state field editable first.
Please mark correct answer if this answers your question.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 11:19 PM
how we can arrange the order its coming at last position
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 11:25 PM
@jobin1 Add the 4th parameter as 0
g_form.addOption('state',104,'<CHOICE LABEL HERE>', 0);
ServiceNow Community Rising Star, Class of 2023