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.

Show Error message on UI page

chidanandadhath
Kilo Guru

Hi All,

I want to show a error message in the same dialog window based on condition in clident script UI Page like below

if(condition=='true')

{

<show error message>

}

 

could you please let me know how to achieve this.

 

 

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

You can try something like this way. 

 

Define below line in html

 

<span style='color: red;' id="error_msg" class="outputmsg_text"></span>

 

UI Page client side code 

 

if(condition=='true'){

$j('#error_msg').html(getMessage('Could not request without name'));
gel('error_msg').show();
return false;

}	

 

Quick Demo

 

find_real_file.png

 

Reference:

 

https://www.geeksforgeeks.org/how-to-display-error-without-alert-box-using-javascript/

 

If my answer helped you, kindly mark it as correct and helpful.

View solution in original post

4 REPLIES 4

Harsh Vardhan
Giga Patron

You can try something like this way. 

 

Define below line in html

 

<span style='color: red;' id="error_msg" class="outputmsg_text"></span>

 

UI Page client side code 

 

if(condition=='true'){

$j('#error_msg').html(getMessage('Could not request without name'));
gel('error_msg').show();
return false;

}	

 

Quick Demo

 

find_real_file.png

 

Reference:

 

https://www.geeksforgeeks.org/how-to-display-error-without-alert-box-using-javascript/

 

If my answer helped you, kindly mark it as correct and helpful.

Hi Harshavardhan,

 

Thanks a lot for the reply

 

I gave the condition like below

if(condition=='true')

{

 $j('#error_msg').html(getMessage('Please Enter Scheduled Job Name'));
gel('error_msg').show();
return false;

}

else{

$j('#error_msg').html(getMessage('test));
gel('error_msg').show();
return false;

}

 

the else loop is not executing...only its showing the first one..

missing colon in test .

try

$j('#error_msg').html(getMessage('test'));

Thank you very much