Create User Permission automatically

Hi, I have a scenario where I have to set user permission automatically while
creating a new user. Does anyone have an idea how it will be possible?
Thank you

response awaited from team

Hi @519_Hamza_Habeeb @rutikarathod1308:

User permissions are stored in “User Permission” doctype. So, you can easily create permissions programatically from a server script, triggered on user form event.

Something like this:

frappe.get_doc(
			doctype="User Permission",
			user=user,
			allow=doctype,
			for_value=name,
			is_default=is_default,
			applicable_for=applicable_for,
			apply_to_all_doctypes=0 if applicable_for else 1,
			hide_descendants=hide_descendants,
		).insert(ignore_permissions=ignore_permissions)

Hope this helps.

1 Like

can u explain for more? i want “For Value” override with another field, thanks