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

yes, I want to show alert messages if the field is not populated.

Hi Shivani,

Are you doing this onSubmit?

Why not set those mandatory if they are always required to be populated on the form?

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

actually i can't keep owner field mandatory coz in another case i need to keep it blank and put value into another field.

Hi Shivani,

Then you can do this using onSubmit client script and stop form submission if fields not populated.

Regards

Ankur

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

When do you want to display that error message on the form ??