Disable Attachments

DreDay3000
Giga Guru

Hello, I would like to disable attachments on a RITM is the approval field is not set to Approved

DreDay3000_0-1718638807987.png

 

 

4 REPLIES 4

Yashsvi
Kilo Sage

Hi @DreDay3000,

Create a new Business Rule:

When: Before

(function executeRule(current, previous /*null when async*/) {
    var attachment = new GlideSysAttachment();
    var attachments = attachment.getAttachments('sc_req_item', current.sys_id);
    if (attachments.hasNext()) {
        gs.addErrorMessage('Attachments cannot be added unless the approval is Approved.');
        current.setAbortAction(true);
    }
})(current, previous);

Thank you, please make helpful if you accept the solution.

Anurag Tripathi
Mega Patron
Mega Patron

What do you mean by disable attachments? 

Do you want to make sure no new attachments can be added?

OR

No Attachments can be removed (if attachments are already added)

Or 

Just Hide All attachments added and no new attachments can be added

-Anurag

users with or without the itil role can attach files

Slava Savitsky
Giga Sage

Your script looks good, except that 3 means Rejected (unless you changed that in your instance). The OOTB value for Approved is 2. Also note that for this to work, you need to add Approval field to the form layout.