Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Uiscripts.context.user.role comes back "undefined"


#1

Hi guys,

I’m attempting to check if a specific role exists in order to show / hide a button on the Suites overview page. Unfortunately the “role” field comes back as “undefined”.

The following all return valid data:

uiscripts.context.user.id
uiscripts.context.user.name
uiscripts.context.user.email
uiscripts.context.user.is_admin
uiscripts.context.project.id

#2

Hello Glenn,

Thanks for your posting. This should be ‘role_id’ actually and I’ve just updated the documentation. The role_id refers to the database ID of the role and not the actual name, so you would need to look up the IDs in the administration area under Administration > User & Roles (just hover your mouse over the edit link and the ID is then part of the link URL).

I hope this helps and please let me know in case you have any further questions.

Regards,
Tobias


#3

Hi Tobias,

That worked, thanks :slight_smile: