Unable to Set "Work Notes" mandatory for sc_task table

CharanV66187530
Tera Expert

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

}

1 ACCEPTED SOLUTION

CharanV66187530
Tera Expert

We have to use both Client Script and Script Include to make mandatory. 

View solution in original post

9 REPLIES 9

@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 Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

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;
}

 

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

CharanV66187530
Tera Expert

We have to use both Client Script and Script Include to make mandatory.