It's all about the answers!

Ask a question

Read-only work item attributes based on role and attribute


Dominik L. Blystak (1622) | asked Jun 22 '12, 5:07 a.m.
edited Apr 08 '13, 12:44 p.m. by Ralph Schoon (58.0k23642)
I'm using RTC 3.0.1.3, I have added an boolean attribute called "Contract relevant" to the epic work item and I would like to make epics with that attribute editable only to project managers.

I've read about script based validations and conditions in the wiki but I could not find a way to determine what role the current user has. How can I determine the users current role by using Java-Script or a Java customization?

In the first place conditions with the operation behavior settings seemed most appropriate for this task but as far as I understood they are only used to determine which additional attributes have to be set, when a condition matches. Is this assumption right and should I use validations to solve the problem or is there a better way?


2 answers



permanent link
Michele Pegoraro (1.8k12114101) | answered Jun 22 '12, 6:30 a.m.
Hi,
if you want to use advisor (server side Java costumization) you can obtain the roles of an user using this methods:

IRole[] contributorRoles = processServerService.getServerProcess(processArea).getContributorRoles( contribHandle, processArea);

where processArea could be a TeamAreaHandle or a ProjectAreaHandle and you can obtain contribHandle using getAuthenticatedContributor() method (your advisor must extend AbstractService).

ProcessServerService could be obtained by getService() method.

But I think you could easily obtain the same result using process configuration permissions and giving the permission to save that attribute only to specific roles. Other users can edit it but cannot save it.

Michele.

permanent link
Ralph Schoon (58.0k23642) | answered Apr 02 '13, 4:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
As far as I can tell, it is not possible to access the role of a user in script based customization.
If you want to protect certain attributes and make them read only by role, you could try to follow https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Providing_new_customizations_imp and create a condition based on Java. And use the read-only for condition precondition (available in RTC 4.x). See https://jazz.net/library/article/1093 for more information.

Otherwise you could implement an Advisor (precondition).  This post shows an advisor: http://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/ and other posts on the blog show the operation ID you want to use http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ as well as API to access the roles http://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ .

Follow  http://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ and the links to the Extension Workshop to learn about how to setup your environment.

Your answer


Register or to post your answer.