How can we restrict a user from renaming attachments after change request has been approved. I have tried onload client script using function g_form.disableattachments() but it restricts users from deletion and uploading new attachment but it allows

harsha harsha
Tera Contributor

How can we restrict a user from renaming attachments after change request has been approved. I have tried onload client script using function g_form.disableattachments() but it restricts users from deletion and uploading new attachment but it allows users to rename the existing attachment.

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi Harsha,

You can use a before update query filtered on table name = change_request and file name changes.

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

	// Add your code here
	var chgGR = new GlideRecord(current.table_name);
	if(chgGR.get('sys_id',current.table_sys_id)){
		if(chgGR.getValue('approval') == 'approved'){
			current.setAbortAction(true);
			gs.addErrorMessage(gs.getMessage("Attachment names can not be modified after a change request has been approved."));
		}
	}

})(current, previous);

find_real_file.png

 

If my reply helped with your issue please mark helpful 👍 and correct if your issue is now resolved.
By doing so you help other community members find resolved questions which may relate to an issue they're having.

View solution in original post

1 REPLY 1

Kieran Anson
Kilo Patron

Hi Harsha,

You can use a before update query filtered on table name = change_request and file name changes.

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

	// Add your code here
	var chgGR = new GlideRecord(current.table_name);
	if(chgGR.get('sys_id',current.table_sys_id)){
		if(chgGR.getValue('approval') == 'approved'){
			current.setAbortAction(true);
			gs.addErrorMessage(gs.getMessage("Attachment names can not be modified after a change request has been approved."));
		}
	}

})(current, previous);

find_real_file.png

 

If my reply helped with your issue please mark helpful 👍 and correct if your issue is now resolved.
By doing so you help other community members find resolved questions which may relate to an issue they're having.