User should not able to delete attachment in change ticket after Scheduled state

Sangeeta_Nayak
Tera Contributor

Hi All,

 

I have a requirement to restrict users from deleting attachments in a change ticket once the state changes to "Scheduled." However, users should still be able to add attachments in any state.

I have implemented a before/delete Business Rule, but it is not showing any error. The system allows the user to delete the attachment, and after the page refreshes, the document reappears. This partial behavior is confusing for the user. Although the attachment is not actually deleted, there is no error message, and the user only realizes the attachment wasn't deleted after the page refreshes. However, after clicking the remove button, it appears as if the attachment was removed.

I am looking for an approach where, if the user tries to remove an attachment after the state is "Scheduled," the system will throw an error.

 

Thanks

2 ACCEPTED SOLUTIONS

Brian Lancaster
Tera Sage

Can you share your business rule? Was your business rule on the attachment table?

View solution in original post

I got an ACL to work. I had to modify an OOB ACL to get it to work. As you can see from the screenshot below it removes the checkboxes next the the attachments and the remove button is not visible.

BrianLancaster_0-1732300234795.png

The ACL I modified can be found here  https://[instance].service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=0c66472a0a0a0b82017c1f3df66a3fe7 
I added the following code right after var tableName = current.table_name;

 

//Handel change request files
    if (tableName == "change_request") {
        var changeRequest = new GlideRecord('change_request');
        if (changeRequest.get(current.getValue('table_sys_id'))) {
            if (changeRequest.state >= -2) //Value of "Scheduled" state
            {
                return false;
            } else {
                return true;
            }
        }
    }

 

 

View solution in original post

8 REPLIES 8

Sangeeta_Nayak
Tera Contributor

Hi @Brian Lancaster , 

 

I did not get the proper solution. Could you please help me on this? Can we achieve through ACL? 

I just tried your Business rule and it works for me. It does not display the error message but it does prevent the removal of the attachment. Once you reload the form you will see that the attachment is still there. I'm note sure you can display the error message since the BR is on the attachment table.

That might confuse the user. Although the attachment is not actually deleted, there is no error message, and the user only realizes it wasn't deleted after the page refreshes. If we cannot display an error message because the Business Rule is on the attachment table, can we disable the "Remove" button once the Change Request state changes to "Scheduled" or beyond? However, users should still be able to add attachments in any state.

I got an ACL to work. I had to modify an OOB ACL to get it to work. As you can see from the screenshot below it removes the checkboxes next the the attachments and the remove button is not visible.

BrianLancaster_0-1732300234795.png

The ACL I modified can be found here  https://[instance].service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=0c66472a0a0a0b82017c1f3df66a3fe7 
I added the following code right after var tableName = current.table_name;

 

//Handel change request files
    if (tableName == "change_request") {
        var changeRequest = new GlideRecord('change_request');
        if (changeRequest.get(current.getValue('table_sys_id'))) {
            if (changeRequest.state >= -2) //Value of "Scheduled" state
            {
                return false;
            } else {
                return true;
            }
        }
    }