Making an attachment mandatory in a catalog item

SK41
Giga Guru

Hi,

 

I have a requirement to make the attachment mandatory on the catalog item. User does not use service portal, so I cannot use "mandatory checkbox" in the catalog. My requirement is to check if the user has attached the file before submitting the catalog. If not, show them error message "Please attach a file".

 

How can I achieve that?

Thanks!

1 ACCEPTED SOLUTION

Hi Anurag,

 

I used below code in onSubmit catalog client script and it worked for me:

 

var count = getCurrentAttachmentNumber();
    if(count == 0){
        g_form.addErrorMessage('You must add an attachment');
        return false;
    }

 

View solution in original post

17 REPLIES 17

Yes, I used the same code sometime back and it worked like a charm!

Thanks!

Hello @Ankur Bawiskar ,

Is there any other code that should work for Both Native UI and also for Portal?


Thanks,

@Raviteja24 

Can you post a new question and tag me there as this is an old thread?

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