Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

  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

https://jazz.net/forum/questions/92685/how-to-use-javascript-to-retrieve-value-of-contributor-attirbute

 but it gives creator not current user and roles.

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

Thanks,

Kavita

0 votes

Comments

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. 

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 https://jazz.net/forum/questions/65090/excluding-someone-from-precondition-checking
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.

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.

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?

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.

Kavita, if you consider a Java Extension, please look here for a similar discussion and some hints where to get information: https://jazz.net/forum/questions/97599/how-to-use-javascript-api-to-get-all-the-users-idaccounts-in-an-role-by-the-role-name/97645

showing 5 of 6 show 1 more comments


2 answers

Permanent link
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. https://jazz.net/library/article/1093 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.

1 vote

Comments

 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.

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.

Ralph,

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 ?

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

You could have a closer look her: https://jazz.net/wiki/bin/view/Main/CustomPreconditionsTable#operations 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: http://rsjazz.wordpress.com/2012/12/14/do-not-modify-the-triggering-element-in-an-operationadvisor/ . 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
After reading more, i stumbled across this content https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Providing_new_customizations_imp  . 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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,936
× 1,220

Question asked: Jan 02 '13, 7:03 a.m.

Question was seen: 6,521 times

Last updated: Mar 21 '13, 11:34 a.m.

Confirmation Cancel Confirm