Set display value of choice field is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 04:58 AM
Hi All,
if choice is not available in the form we can able to set the value in field in client script
In choice type if one of the choice value is not available in the form based on some criteria we can able to set that choice in the choice field using client script .
for example in incident form 'New' choice will not be available in the form once incident state is moved to 'inprogress state',the choice "new" is not available. But i need to set the state filed to 'New' if assigned to field is empty.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 05:12 AM - edited 01-23-2024 05:13 AM
Hi,
you can try below logic:
g_form.addOption('state',1,'New'); // add option by providing value and label
g_form.setValue('state',1); // set the field value
Since OOB state field of task is of type integer it will not accept string values.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0755115
Thanks
Anil Lande