We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

how to check if attachments are added before submitting the RITM?

saranyavs
Tera Expert

How to check if attachments are added to the catalog item before submitting the Request?

 

Regards,

Saranya

 

10 REPLIES 10

SohamTipnis
Kilo Sage

Hi @saranyavs,

 

You can just make the attachment mandatory using a checkbox in the catalog item.

You can use the below image for reference:

 

SohamTipnis_0-1770983288733.png

 

If you find my answer useful, please mark it as Helpful and Correct ‌😊


Regards,
Soham Tipnis
ServiceNow Developer ||  Technical Consultant
LinkedIn: www.linkedin.com/in/sohamtipnis10

Ankur Bawiskar
Tera Patron

@saranyavs 

If you users are only using Portal then this checkbox will achieve your requirement.

AnkurBawiskar_0-1770983662852.png

 

If they are using both Native + Portal then this will work in both places

Create onSubmit Catalog Client Script

UI Type - ALL

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

    try {
        if (window == null) {
            // portal
            if (this.document.getElementsByClassName('get-attachment').length != 1) {
                alert('You must attach file before submitting this request.');
                return false;
            }
        }
    } catch (ex) {
        // native view
        var length = getSCAttachmentCount();
        if (length != 1) {
            alert('You must attach file before submitting this request.');
            return false;
        }
    }
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hi Ankur,

 

I tried this, but some javascript error is showing in browser after submit.

 

saranyavs_0-1770997328210.png

 

the issue is due to some code in script ? because i can see below message in client script.

 

saranyavs_1-1770997394331.png

 

 

@saranyavs 

try to make Isolate Script= False for your client script

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@saranyavs 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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