Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to make attachment mandatory in application from when user select the drop down

Tharun13
Tera Contributor

Hi, 

 

I have application table and drop-down values

 

field name is : Service manager- choices(dtit and non dtit)

when user select "non-dtit" then make attachment mandatory.

 

Regards,

Tharun

3 REPLIES 3

AshishKM
Kilo Patron
Kilo Patron

Hi @Tharun13 ,

Can you please share more details about the application table, Is it something OOTB, please name it here.

If its some kind of form ( not the catalog item ) you can write UI Policy over that table and check for Service Manager Choice value  and set the attachment field mandatory.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Alka_Chaudhary
Mega Sage
Mega Sage

Hello @Tharun13 ,

Write a before-insert/update business rule with the condition that the service manager is non-DTIT. Add the following script to check if an attachment is present.

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

    // Add your code here
    var checkAtt = new GlideRecord('sys_attachment');
    checkAtt.addQuery('table_sys_id', current.sys_id);
    checkAtt.query();
    if (!checkAtt.hasNext()) {
        gs.addErrorMessage('Please add attachment while creating an record!!!');
        current.setAbortAction(true);
    }

})(current, previous);

Please mark my answer as correct and helpful if it resolves your query.

Thanks,

Alka

Sumanth16
Kilo Patron

Hi @Tharun13 ,

 

Please refer below article:

 

https://www.servicenow.com/community/developer-articles/possible-ways-for-making-an-attachment-manda...

 

 

 

 

Thanks & Regards,
Sumanth Meda