Disable renaming or delete/remove attachment option for a table

Community Alums
Not applicable

Hi All,

I have a requirement that "only the user who attached that attachment should be able to rename the attachment or delete/remove the attachment others shouldn't" for a particular table(custom table).

@Ankur Bawiskar Any idea?

 

Thanks,

Bala

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can try to use before update BR on sys_attachment and check if the logged in user is the created by of that sys_attachment

For Remove/Delete ensure you have correct table level DELETE ACL

Actually both your requirements can be handled via before update/delete business rule

BR: sys_attachment

Before Update AND Delete

Condition: current.table_name == 'incident'

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if(gs.getUserName() != current.sys_created_by){
		gs.addErrorMessage("You are not allowed to update/delete the file as you are not the one who attached it");
		current.setAbortAction(true);
	}

})(current, previous);

regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Hi,

create BR in your scope and test once.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader