Set display value of choice field is not working

Sangeetha8
Tera Contributor

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.

1 REPLY 1

Anil Lande
Kilo Patron

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

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande