Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Restrict the deletion of attachment

Tanya10
Tera Contributor

Hi ,
I have a requirement to restrict deletion of attachment post submission of request for particular catalog item.
I followed this -https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0825743
It works well, but on portal even though attachment is not deleted it adds an additional comment saying deleted attachment

Tanya10_0-1762407072238.png

 

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Tanya10 

should not happen.

share steps to reproduce and which portal page etc is this

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

its esc portal and I have written 2 BR,one on attachment and another on attachment doc table.The BR are almost same just dot walking is differnt

    var tableID = current.table_sys_id;
    var tableName = 'sc_req_item';
    var catalogName;

    var grRequest = new GlideRecord(tableName);
    if (grRequest.get(tableID)) {
        catalogName = grRequest.getValue('cat_item');
        if (catalogName == 'xyz') {
            if (!gs.hasRole('admin')) {
                gs.addInfoMessage("You are not allowed to delete attachments for this item.");
                current.setAbortAction(true);
            }
        }
    } else {

        gs.print("Record not found.");
    }




@Tanya10 

so you are stopping user from deletion of attachment?

is that user clicking on delete icon?

you didn't mention which portal page is this? form? ticket?

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

that's correct.Page is ticket, user should not be able to delete from anywhere once request submitted.Let it be portal/native veiw