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.

How to add info message when a field is not empty in onload catalog client script

GUSNOW13
Tera Contributor

Hi,

I want to add an info message when List collector variable on the form is not empty and have to achieve with onload catalog client script. This message has to be displayed in SC task when we open the request. How to achieve this?

1 ACCEPTED SOLUTION

Sagar Pagar
Tera Patron

Hi @GUSNOW13,

 

Create Catalog UI policy wit condition as -

Variables - variable_name is Not Empty

 

Execute of true:

g_form.addInfoMessage("Add your message here"); // check correct syntax for method 

 

Execute of false:

g_form.clearMessage(); // check correct syntax for method

 

Note - Applies on Catalog task only check box - True.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

View solution in original post

2 REPLIES 2

RaghavSh
Mega Patron

Create a catalog client script o your catalog item (applicable to sc task only) with below code:

if(g_form.getValue('list_collector variable_name')==' ')
{
g_form.addInfoMessage("type your message here");
}

Raghav
MVP 2023
LinkedIn

Sagar Pagar
Tera Patron

Hi @GUSNOW13,

 

Create Catalog UI policy wit condition as -

Variables - variable_name is Not Empty

 

Execute of true:

g_form.addInfoMessage("Add your message here"); // check correct syntax for method 

 

Execute of false:

g_form.clearMessage(); // check correct syntax for method

 

Note - Applies on Catalog task only check box - True.

 

Thanks,

Sagar Pagar

The world works with ServiceNow