Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

@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  ||  10x 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  ||  10x 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