How to display popup message when variable attachment is not selected

Renu9
Tera Contributor

Hi All,

I have created a variable named Attachment1 and the type as Attachment in record producer. I made it mandatory.

When someone submits the request via record producer, it has to display a message "Please fill the attachment along with screenshot ". I created a UI policy and in the run script I put a message like below.

Renu9_0-1698745030556.png

 

But it is displaying common message "Some fields are incomplete: Attachment1 "

 

Please guide what changes are to be made. I want error message should appear below field

 

1 ACCEPTED SOLUTION

Vishal Birajdar
Giga Sage

Hi @Renu9 

 

The mandatory error message will take precedence over custom messages & If mandatory fields not filled anyhow he/she will not able to submit the request.

Still if you want to display custom message then , make attachment variable non-mandatory and write onSubmit client script :

 

function onSubmit() {
   //Type appropriate comment here, and begin script below

   if (g_form.getValue('attachment_variable') == ''){
	g_form.addErrorMessage('Please attach the file');
	return false;
   } else {
	//g_form.addErrorMessage('Attached');
   }
   
}

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

1 REPLY 1

Vishal Birajdar
Giga Sage

Hi @Renu9 

 

The mandatory error message will take precedence over custom messages & If mandatory fields not filled anyhow he/she will not able to submit the request.

Still if you want to display custom message then , make attachment variable non-mandatory and write onSubmit client script :

 

function onSubmit() {
   //Type appropriate comment here, and begin script below

   if (g_form.getValue('attachment_variable') == ''){
	g_form.addErrorMessage('Please attach the file');
	return false;
   } else {
	//g_form.addErrorMessage('Attached');
   }
   
}

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates