Unable to Set "Work Notes" mandatory for sc_task table

CharanV66187530
Tera Contributor

Hi @everyone,

Can any one help me on how to make mandatory "work notes" in sc_task table by using UI action. I tried i am able to set "Notes" section instead "work Notes".

function onclieck(){

g_form.setmandatory('work_notes');

}

8 REPLIES 8

@CharanV66187530 

As already said your syntax is wrong

55.png

šŸ’” If my response helped, please mark it as correct āœ… and close the thread šŸ”’ā€” this helps future readers find the solution faster! šŸ™

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

In Ui Policy  ->Script tab->Execute if true, 

write it and check: 

 

function onCondition() {
           g_form.setMandatory('work_notes',true);
       }
 
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Hello @CharanV66187530 
1. The spelling of click is incorrect.

VishalJaswal_0-1778165391701.png

2. When you use setMandatory('field_name', 'you specify here as true or false');


Hope that helps!

VaniMadhuri
Tera Expert

Hi @CharanV66187530 

 

Work Notes is not a normal field, it belongs to journal fields.

g_form.setMandatory() does not work reliably on journal fields like work_notes and comments. That’s why it’s not enforcing.

Use g_form.getValue() and block submission. Try below code it may work for you

function onClick() {

    var notes = g_form.getValue('work_notes');

    if (!notes) {
        g_form.addErrorMessage('Work Notes is mandatory');
        return false; // stop action
    }

    // allow action
    return true;
}

 

f you found this useful, feel free to mark it as Helpful and accept it as the solution.
Regards,
VaniMadhuri