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.

print values on form using business rule

Shivani Khedek1
Giga Contributor

I have written a business rules on a custom task table, which should print error messages on form if any of the mentioned field value is not given.

for example, i have a field 'owner ' on which i have written a business rule which should mark state to closed complete if value in owner field changes. Along with this implementation I want an error message to be displayed on form below owner field that 'error assign owner'.

I have tried implementing:

gs.addErrorMessage('Form Error Message Text');

gs.addErrorMessage(gs.getMessage("Choose approval or rejection"));

gs.addErrorMessage('Choose approval or rejection');

g_form.addErrorMessage('This is an error');

current.approval.setError('Choose approval or rejection');

current.approval.setDisplayValue('Choose approval or rejection');

current.approval.setValue('Choose approval or rejection');

 

can someone help me to print values on form using business rule?

 

thank you,

Shivani.

 

13 REPLIES 13

when the owner field remains empty.

Create after update business rule :

Add this script :

 

if(current.owner =='') //Here owner should be backend value
{
gs.addErrorMessage("Give your message");
}

You can also achieve this by using OnLoad Client script :

 

var gr = g_form.getValue("owner");
if(gr=='')
{
g_form.addErrorMessage("Add message here");
}
}

Jaydeep Parmar
Kilo Guru

Hi,

Use onChange() Client Script

 function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

check=g_form.getValue("owner");

if(check=="")

 g_form.addErrorMessage("Error Msg");

}