Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

make the multi line text variable mandatory even if it has a default value

Codi
Tera Contributor

Hi Everyone,

Is it possible to make a multi line text variable mandatory even if it has a default value?

If yes is there any documentation that I can use as a reference.

 

Thanks in advance.

2 REPLIES 2

Community Alums
Not applicable

Hi @Codi ,

Yes , you can but you will need to write a Client script to handle the same.

Here is a Sample Script  where you can use Onsubmit client script to set the fields mandatory if they are not changed by user

(change backend name of variables if needed)

 

function onSubmit() {
    var field1 = g_form.getControl('summary'); //Get the 'Caller' field control
    var field2 = g_form.getControl('description'); //Get the 'Short description' field control

   
    if (!field1.changed) {
        g_form.setMandatory('summary', true);
    }
    if (!field2.changed) {
        g_form.setMandatory('description', true);
    }
    if (field1.changed && field2.changed) {
        return true;
    }
    return false;
}

 

 

Hi @Community Alums 

When I try the script that you provided and test it, it allows me to submit even though the I didn't update the field.