| || |
Require a field change
Hey guys ... I am stuck on a particular piece of functionality that I am trying to set up using QC scripting.
The scenario is that a defect status is updated from New to Open. When this happens I need to force the user to update the assigned to value but setting the field required will not work. The reason it will not work is because there is already a value there so it passes.
I need to force them to actually change the existing value but I cannot figure out how.
Has anyone done something like this in the past?
Re: Require a field change
I assume that you do not mind the order in which things are changed : users can first change the Assigned to field and then the Status field, or they can change first the Status field and then the Assigned To field.
If that's the case, you cannot handle your requirement in FieldChange events : you need to make sure that both fields have been changed in the CanPost event.
There are two ways to do that :
1. rely on the IsModified property of the Bug_Fields.Field(<field name> objects. I wouldn't follow that route because I noticed that it is enough to display the user list (without picking any value, or picking the current value) for that flag to be set to True.
2. Save the current values for the Status and Assigned To fields upon moving to the defect (or creating a new one). You would save these values in global variables of the workflow. Then in the CanPost event, check that the Assigned To field has indeed a new value if the Status field previous value was not Open and its new value is Open. If your requirement is not fulfilled, the CanPost event should return False (and you should warn the user through a message box).