The CreatorCon Call for Content is officially open! Get started here.

Attachments in ServiceCatalog

harshi_ramesh
Tera Expert

Hello All

I have been working on restricting the number of attachments to be added on a catalog form. You may ask to use three variables with type 'Attachment', but it does not look good or give a good interface.

 

So, I developed a catalog script of 'onSubmit',  attaching below.
But the issue is this shows a infoMessage: This catalog client script is not VA supported due to the presence of the following variables in the script: this.document.getElementsByClassName.length.

 

Even tried with g_form.getAttachments(), same.

function onSubmit() {
   //Type appropriate comment here, and begin script below
   var attacha = this.document.getElementsByClassName('get-attachment').length;
   //var attacha = g_form.getAttachments();
   if(attacha>3)
   {
	g_form.addErrorMessage('Maximum number of attachments is 3');
	return false;
   }
   return true;
}

 

Would appreciate if we have any workaround which can solve this by Catalog client script itself.

 

Thanks!

5 REPLIES 5

Rafael Batistot
Kilo Patron

Hi @harshi_ramesh 

 

Your script is correct

 

kindly check if the Isolate Script field is set to False for this Catalog Client Script to ensure DOM manipulation works

 

https://www.servicenow.com/community/itsm-forum/how-to-check-attachment-before-on-submit-client-scri...