How can we make Worknotes/Additional Comments Mandatory on click of a UI action

Sanket Pawar
Tera Contributor

How can we make Worknotes/Additional Comments mandatory on incident form after clicking on UI action?

1 ACCEPTED SOLUTION

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Sanket Pawar ,

 

If u want to make Additional Comments/ Worknotes as mandatory using UI action u need to make that UI action as Client True (click the checkbox for client field) & then u will be able to use this command

 

g_form.setMandatory('comments',true);
g_form.setMandatory('work_notes',true);

 

Thanks,

Danish

 

View solution in original post

4 REPLIES 4

Kushal09
Tera Guru

Use client side UI action and make sure the client check box is ticked in the UI action.
Code can be something like this:

 

 

g_form.setMandatory('field_name', true);
g_form.save();

 

 

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Kushal

Ratnakar7
Mega Sage
Mega Sage

Hi @Sanket Pawar ,

 

You can write below script either on update Business Rule or in UI action:

    var commentsField = current.work_notes.toString().trim();
    if (commentsField === '') {
        gs.addErrorMessage('Worknotes or Additional Comments is mandatory.');
        current.setAbortAction(true);
    }

 

Thanks,

Ratnakar

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Sanket Pawar ,

 

If u want to make Additional Comments/ Worknotes as mandatory using UI action u need to make that UI action as Client True (click the checkbox for client field) & then u will be able to use this command

 

g_form.setMandatory('comments',true);
g_form.setMandatory('work_notes',true);

 

Thanks,

Danish

 

Dr Atul G- LNG
Tera Patron
Tera Patron

@Sanket Pawar 

 

You can use UI policy as well to make it mandatory on condition check.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************