Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Restriction on Editing/Renaming HR Case Attachments

smiley4
Tera Contributor

As an HR Agent, we need to restrict requestors from editing or renaming attachments that have been added by an HR Agent or other users.

Requestors should be able to edit or rename attachments that they have uploaded themselves. However, they should not be able to edit or rename attachments uploaded by agents/other members

This restriction should apply only to HR Cases in the ESC portal.

 

 

smiley4_0-1790113253938.png

 

Any guidance on the best approach to implement this would be greatly appreciated.

 

Thanks

1 REPLY 1

Vishal Jaswal
Tera Sage

Hello @smiley4 

It is first important to understand where this pencil / edit icon/button is being coded:

Make a right click on this pencil icon and click Inspect (browser: Chrome) and then you will find out below highlighted code is responsible:

VishalJaswal_0-1790114515027.png


If you make a right click on this highlighted code, then you can cut it and you will notice the pencil icon is gone just for you and just for this session like if you refresh the webpage then it will be back again.

You can copy the button name "attachment.canWrite" and then navigate to All > Service Portal > Widgets (personalize the list to show Body HTML template column) or Apply the filter Body HTML template contains attachment.canWrite

You will find out that it is defined in Out of the box SC Order Guide widget. 

VishalJaswal_1-1790114691179.png

 

So, this is the widget which maybe used by multiple portals within your organization which you need to identify then clone this widget so that everyone starts using the clone and you need to modify the widget to hide this button based upon your condition/scenario.

So, the above may or may not be a viable solution.

The other option is Access Control List (ACL):

Post Elevate roles under your profile, Navigate to All > System Security > Access Control (ACL) and then click New and Create a new ACL as shown below (please update the table name):

VishalJaswal_2-1790116154506.png

VishalJaswal_3-1790116164703.png

if (current.table_name == 'sc_req_item') { //update the table name
    var attaddedBy = new GlideRecord('sys_user');
    if (attaddedBy.get('user_name', current.sys_created_by)) {
        answer = (attaddedBy.sys_id == gs.getUserID());
    } else {
        answer = false;
    }

} else {
    answer = true;
}


Validation Results:

VishalJaswal_4-1790116219784.png



VishalJaswal_5-1790116228123.png

VishalJaswal_0-1790116906668.png

 

 





Hope that helps!