Script to make a field mandatory after clicking Close Complete

Rylie Markle
Tera Contributor

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. find_real_file.png

9 REPLIES 9

Aman Kumar S
Kilo Patron

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();

}

Best Regards
Aman Kumar

Hi @Rylie Markle 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

 

Best Regards
Aman Kumar

PrashantLearnIT
Giga Sage

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
********************************************************************************************************

Thank you for that. I followed the article and I added the bottom part of this script to try to run the server-side script, but it wasn't successful. Any ideas?

find_real_file.png