Page 1 of 1

Iterating through project roles

Posted: Mon Oct 16, 2017 10:30 am
by jriimala
Need help how to read specific project role value from variable. Below function returns mutable Map of IContextId and Collection of roles based on

https://almdemo.polarion.com/polarion/s ... textId...-

Trying to find out, if variable has project_assignable role in it and if so then doing something.

In this case variable can have project_user project_assignable project_reviewer project_approver in it, but would like to learn how to iterate $r variable so that I could check specific value from it.

#set($role = $securityService.getContextRolesForUser($f.id,$prj.getContextId()))

#foreach($r in $role)
$r
#end

Pls provide help with example, thx in advanced.

Re: Iterating through project roles

Posted: Thu Nov 30, 2017 2:16 pm
by martins
If you just want to check if a user has a certain role you can do it like this

Code: Select all

#if($role.contains("project_developer"))
   ## code for all project developers
#if($role.contains("project_user"))
   ## code for all project users
#else
   ## code for all other users
#end

Martin