I want to Remove all roles for the logged in user and then add a role to the logged in user using server side script
I tried this
user_roles = frappe.get_roles()
frappe.msgprint(f'user roles: {user_roles}')
logged_in_user = frappe.session.user
logged_in_user_doc = frappe.get_doc('User',logged_in_user)
# logged_in_user_doc.remove_roles(*user_roles)
logged_in_user_doc.add_roles('Nhcp Dependents View Only')
logged_in_user_doc.remove_roles('Guest',)
frappe.msgprint(f'role has been changed : {frappe.get_roles(frappe.session.user)}')
but it is not working
here is the output, look at 2 and 4 statements