Mandatory Attachments on the Record Producer

Community Alums
Not applicable

Hi,

I want to make Attachments mandatory on the record producer (on the servicenow platform, not the portal). 

I have written a client script using DOM. However, thats going to cause updrade issues. Please see the attached screenshot. My question is what is the alternative method? How can I use glideform API? Anyone has working code?

find_real_file.png

 

Thank you

7 REPLIES 7

John Longhitano
Kilo Guru

I'm not sure if this applies here but there is an out of box checkbox starting in madrid for mandatory attachments on catalog items.  This only works for Portal I think though and I'm not sure if it's available on record producers.

find_real_file.png

Community Alums
Not applicable

Hey John,

 

I am using that. that works perfectly fine on portal. However, I need mandatory attachments on the backend (Servicenow platform).

Ashok Antony1
Kilo Expert

How about a "before" BR?

Code:

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

var gr= new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id",current.sys_id);
gr.query();

if (!gr.hasNext()) {
gs.addErrorMessage("Attachment is required to submit this Request");
current.setAbortAction(true);
}
})(current, previous);

Something like this should work. I tried and it does prevent from submitting a Case without attachment. Of course there needs some modifications to suit your needs perfectly but this would be a good start.