Script to make a field mandatory after clicking Close Complete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 10:40 AM
I wrote a script to make a field mandatory when the fulfiller clicks Close Complete. The script is working for that part, but after the fulfiller completes the field and then clicks Close Complete again, the case doesn't actually close.
What do I need to add to this script to get the case to actually close after the field is filled in and the fulfiller clicks Close Complete. I know something is missing but I'm not sure what. Thanks in advance. Below is my current script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 11:00 AM
Hey,
That is because you are not doing anything in the else part, so lets say your field is not empty, then add a else statement.
if(......){
//your code
}
else{
g_form.setValue("state",3);
g_form.save();
}
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 02:37 PM
Hi
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 11:01 AM
Hi Rylie,
You have to run the client and server-side script, for example, you can see that below:
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Best Regards,
Prashant
If my answer helped you in any way, please mark this answer as helpful and correct.
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 12:05 PM