Highlighted
forumadmin Absent Member.
Absent Member.
10052 views

Need to


Discussion posted 3/6/08 by George Bonvanie
Details:

kaufmanjc

I have a state with transitions that should only be used by the "current owner" (not everyone in the associated privilege group).
TeamTrack doesn't work that way (if it does, I'd love to know how).
Sorry about the title of this post - I started the message and neglected to finish the title!
I am trying to write a teamscript that will be executed as a pre-transition script that will check if the user performing the transition is the current owner.
If the user is NOT the assigned owner, then the user is provided an error message and I want the user to have an "okay" button or something that will return them to the main window (i.e., cancel the transition).
My script correctly checks the current user against the owner, and if they are not the same, gives the error - but then it allows the user to edit the available fields and save the record! I.e., the transition completes as required.
Obviously, I am not using the correct command in TeamScript, and I can't seem to find anything in the documentation to tell me which command I should be using.
So, TeamScript ghurus, can you help me out?
Thanks in advance!
Janet
[Updated on 11/7/2007 2:02 PM]
Posted 11/7/2007 2:02 PM

kaufmanjc

I may have been too hasty - I am unable to get the "get current owner" to work - even when the current user is the current owner, it's giving me a mismatch.
Here's the code - any help would be gratefully appreciated:
option explicit
dim owner
dim currentUser
call shell.item.GetFieldValue("Owner", owner)
currentUser = shell.user.getid()
if owner <> currentUser then
Shell.RedoMessage = "Only the current owner can perform this function (see OWNER field in SYSTEM section to verify who is current owner). Press CANCEL to exit and make another selection. Please note, no field changes you make will be saved."
End if
Posted 11/7/2007 4:27 PM

dlinder

Can you just set the privs that the user can only transition the item if they are the owner, then you don't have to mess with a script at all?
For debugging print out the value of owner and currentUser using Shell.redoMessage and see what the actual values are. Maybe you are comparing and ID vs. the username or something like that.
˜˜
Darius
Posted 11/7/2007 5:44 PM

kaufmanjc

Darius, thanks for the response.
Unfortunately, I cannot limit privs to the "current user" (a single person) in teamtrack - it has to be by group. So, the "update" group is allowed to edit if they are the owner or secondary owner (all my states have primary and secondary owner).
So, in the case of a tester and developer, the developer may be the secondary owner and the tester the primary owner for the Validation Required state. BUT, I don't want the developer to validate the case (there are pass/fail transitions on the Val Req'd state). Since the developer is the secondary owner on the state, they can see the and use the pass/fail transitions - even though they should not.
Thanks for the tip on debugging - I'll try it!
Posted 11/8/2007 7:18 AM

dsaber

would setting a restriction on the workflow level so that only the "owner" group can use the transition work...although that would only work if the groups were mutually exclusive.
if you could get your get id part of the script working, you might try adding in some code to clear out a required field (and make this field read only) when the owner is different from the current user, and place a value in it when they are the same.
Posted 11/8/2007 2:15 PM

kaufmanjc

Dsaber - you've identified one of the problems. People can be in the same owner group, but shouldn't perform the action - only the "current owner".
I'll think about your required field option - interesting idea ;-).
Posted 11/9/2007 12:22 PM

azonderman

Hi Janet,
Something else to consider is that the "Shell.RedoMessage" won't stop the transition if it's set pre-transition. To stop the transition, it would need to be set by a post-transition script.
So you might either go with Dsaber's clever required field option, or you might set up a second script to be run post-transition. You could probably use exactly the same script, in both contexts. I like how informative the error message you get from your script is. It would be hard to match that with an empty required field error message.
Ariela
Posted 11/9/2007 12:56 PM

kaufmanjc

Ariela - that is what I am looking for - something like the Shell.RedoMessage that WILL stop the transition.
I tried putting the same script post-transition and it doesn't work. Or maybe I just don't have it doing it right. Since it is post-transition, it saves any data the user entered before executing the script - or is there something I can put in the script that says "discard any changes - return to original values?"
Posted 11/9/2007 2:38 PM

azonderman

Hmm,
At the place where you selected the post-transition script, did you check the "Re-Run Script if Transition is Invalid" option? If that's not checked, then the script will run once (and stop the transition), but if the user clicks "OK" again (instead of Cancelling as directed), the script won't run and the transition will complete.
Does this match what you see happening when it "doesn't work"?
The info in the fields:
If the transition is cancelled, then the data won't be saved. Scripts are called before any changes are made to the DB on a transition.
You could get the script to clear all the user's changes by loading a Field object for each field and calling GetDBValue() & SetValue() on each one.... but in my opinion it would be simpler to just leave the data in place for the moment.
You might be able to find some way to access the function of the "Reset Form" button, but I don't know how.
Ariela
Posted 11/9/2007 3:53 PM

jocelyncr

Hi, I used this information for a similar problem and it was helpful.
Thanks,
Good luck with this. I'm interested in the resolution.
Posted 2/13/2008 3:38 PM
0 Likes
1 Reply
forumadmin Absent Member.
Absent Member.

Re: Need to


This is an old migrated post that has been assigned status Complete.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.