Check the attachment when resolving the incident

Nagesh5
Tera Contributor

Hello Community Experts,

 

Could you please help me the coding snippet to check the attachment is added or not when resolving incident, If there is no attachment don't allow anything. We are looking for the on submit client script through glide Ajax.

 

 

 

Thanks,

Nagesh

10 REPLIES 10

Thanks for your time to provide above script and unfortunately it's not working. May I know where did you calling hasattachment() function in client side?

You are right, there is a slight error in this script,

In case You should use business rules instead of include scripts...

 

Because using a Before Update Business Rule  can be a more robust approach for handling validations like checking attachments before updating a record. This method ensures that the validation occurs on the server side, which can be more reliable and less dependent on client-side interactions.

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Nagesh5 

you can use before update BR instead of glideajax

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
if(!current.hasAttachments()){
gs.addErrorMessage('Please add file before resolving');
current.setAbortAction(true);
}

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Thanks for the response and we can achieve through BR,But we are looking for glide Ajax on submit client script to display pop up message. Can't we achieve through glideAjax,If yes could you please provide code snippet?

 

Thanks,

Nagesh 

@Nagesh5 

yes you can but if it can be achieved using BR I will recommend that.

using onSubmit + GlideAjax will require you to use synchronous GlideAjax so that it waits till the response comes from server side.

what did you debug in the above script include based approach?

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