Suppress Permission Error Message

Hello,

There are few Custom Action Button in my doc as shown in first figure. Each button create new/open existing document related to it.

All users are not permitted to view each of them. Thus, system raises permission error as shown below image.

image

Please guide me to suppress this message.

Regards
Mijan

You could show/hide the buttons based on the user. I use this code to hide buttons I don’t want my general users to access. I think there’s also a frappe.get_roles() function, but I haven’t used this.

// Hide based on user type --------------------------------------
var isAdmin = frappe.session.user == 'Administrator'; // Identify if user is Administrator

if (isAdmin) {
	// Show button for Admin
	frm.add_custom_button(__("console.log"), function () {
		console.log(frm);
	});
}

Thanks. Your suggestion gives me idea to address my requirements.