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
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
2 answers
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.
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.
Comments
Millard Ellingsworth
FORUM ADMINISTRATOR / JAZZ DEVELOPER 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
FORUM ADMINISTRATOR / JAZZ DEVELOPER 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):
Millard Ellingsworth
FORUM ADMINISTRATOR / JAZZ DEVELOPER 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
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
FORUM ADMINISTRATOR / JAZZ DEVELOPER 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?
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER 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: 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