It's all about the answers!

Ask a question

how to get currect user process roles of project area in javascript

kavita herur (5876894) | asked Jan 02 '13, 7:03 a.m.
edited Mar 21 '13, 11:30 a.m. by Ralph Schoon (63.3k33646)

  Hi All,

 I have added read only for condition in my project area with javascript. In java script I want to check current user's preocess role. If user has admin role in project area then he can edit the  work item.

Form net I got the below code

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

But how to get values for contribHandle,processServerService.

 I found another jazz link

 but it gives creator not current user and roles.

please can any one tell me how to get current user roles in javascript.



Millard Ellingsworth commented Jan 03 '13, 7:10 p.m.

There are a variety of permissions and operational behaviors that can be controlled based on role. Have you determined that you can't do what you want via those customizations rather than customizing via scripting/programming? If you can provide some more details, I might be able to suggest a different approach. 

Millard Ellingsworth commented Jan 04 '13, 2:00 p.m.

This was Kavita's reply (it came via email as there may have been an issue with the forum earlier today): 

In JavaScript  If Attr_A == “GHOST” . This works fine. Problem is these pre conditions are defined to default on Save work item (server) in Operational Behavior. 
So It will also be applied to admin. I found solution in
I tried with applying preconditions to “Team member” & delete for default. But with this admin and default user can edit work item & 
I have no idea is there any impact after changing operational behavior from default to team member …. I want only admin can edit work item.  
Can I have ghost JS condition similar to ..
If(( Attr_A==“GHOST” )&&(current_user_role  != “admin”)) then true.  How to access current user role in java script.

Millard Ellingsworth commented Jan 04 '13, 2:06 p.m.

Can you explain how you would like the application to behave rather than what customizations you have attempted? Are you trying to make everything read-only? Is a particular field read-only? We constantly work on improving the product and if you use scripting when other methods are available, you can make upgrading to newer versions more difficult on yourself and your team. It is likely permissions or operational behaviors can be used to solve your issue, but I can't help unless I understand it. As Ralph points out, there is not likely a scripting solution to this.

kavita herur commented Jan 07 '13, 12:09 a.m.

The field Attr_A is present in all work items types.  I want to make read only those WTs in  which  Attr_A 's value is "GHOST". Only admin role can edit those WTs.

 This Java script will be included in pre-conditions. In our PA preconditionds are applied to default role.So it applys to admin role too.

 please can u suggest solution ?

is there way to do with extensions at server side or any other alternate solution?

Millard Ellingsworth commented Jan 07 '13, 12:28 a.m.

So you have a custom field you have added to all work item types whose only purpose is to make instances of that type read-only when someone changes the value to "GHOST" and you want Administrators to be able to edit them no matter what the value of that field is. Do these items ever get out of that state and become editable by non-admins again?

Did you consider the precondition "Read-only for Type and State" and perhaps adjusting workflows to have a State of "Frozen" (or something like that)? I'm not saying that's the answer, I'm just trying to understand what you have tried before you started doing what you are doing now.

Ralph Schoon commented Jan 07 '13, 4:40 a.m. | edited Jan 07 '13, 4:40 a.m.

Kavita, if you consider a Java Extension, please look here for a similar discussion and some hints where to get information:

showing 5 of 6 show 1 more comments

2 answers

permanent link
Ralph Schoon (63.3k33646) | answered Jan 02 '13, 10:52 a.m.
Kavita, as far as I can tell you can't do that with scripts. We had a similar question some days ago. Please go there for the details. will soon talk about JavaScript too and provide an overview of the limitations.

JavaScript is for simple customization and has limits. You can only access the work item itself and only limited for attributes for complex types. So if you want to do quite complex things that exceed the data of the work item available, you should look into a Java Server extension, rather than using JavaScript.

kavita herur commented Jan 09 '13, 9:24 a.m.

 Thanks Ralph,

I got how to get user roles in extensions, but my concern is Read only for condition can be done through extensions?  Currently in RTC 4.0 its feature added through java script to project area.

Ralph Schoon commented Jan 09 '13, 9:34 a.m.

Hi Kavita,

unfortunately I haven't looked into how the condition extensions work and if it is possible to write an extension that is selectable as condition. I would assume it is possible to do something like that, since the condition Advisor is also a Java Extension, but I haven't tried anything like that yet. Sorry. I would consider ceariting an enhancement request/work item.

kavita herur commented Jan 11 '13, 5:52 a.m.


Please can you brief on what on what next to be done? Is it possible with condition Advisors at server side? Is there any link ?

Ralph Schoon commented Jan 11 '13, 6:10 a.m.

You should rethink your approach. Try using Permissions instead. You can limit the permission to manipulate work items in the Team Configuration: . The work item would fail saving for the roles except the admin role.

You could have a closer look her: but I have not found an extension point to create a condition yet. Maybe the actions are an opportunity.It would however also not make the work item read only, but block saving it. You can not use an advisor to set a hidden field, because the advisor extension point does not allow to modify the work item: . An Advisor would only block saving a work item. I see no way to make the work item read only that way. I would consider looking into permissions.

permanent link
Ralph Schoon (63.3k33646) | answered Mar 21 '13, 11:34 a.m.
After reading more, i stumbled across this content  . I think this would be the way to go, if you want to contribute to conditions, but need the Java API. Please be aware you might need to deploy it on the server and the Eclipse client, if i understand it correctly.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.