Possible to Restrict Transition when Custom Field Value gets Changed?

Issue #685 resolved
MAG-II created an issue

Hello -

I have a question, wondering if it's possible to restrict a transition when a custom field gets updated. I notice the JWT Validator called, "A field is/isn't initialized or has/hasn't been modified."

My hope is that when I configure the field, such as "Vacancy" and "hasn't changed" would allow me to only transition if I do not update the custom field, Vacancy. With this validator implemented I am able to transition through the workflow, with or without changing the custom field, Vacancy.

What is it that I am not properly understanding? Thanks in advance for any insight you may have.

Screen Shot 2017-07-13 at 1.52.38 PM.png

Comments (13)

  1. Fidel Castro Armario repo owner

    Hi @michaelgayheart,

    Transition will be blocked by the validator in case field Vacancy has been modified in the transition screen, but this validator will not detect if the field has been edited through edit screen.

  2. MAG-II reporter

    Oh I see, that does make sense. I have been searching tirelessly throughout the Atlassian forums. Is the concept of blocking a transition after a custom field has been edited (through the edit issue screen) even possible?

  3. Fidel Castro Armario repo owner

    @michaelgayheart,

    I think it's possible. This is the solution I propose:

    1. We have to clearly define when you consider that field Vacancy is "rightfully" set. Maybe it's at the moment of issue creation, or after certain transition execution.
    2. We create a text custom field called "Hidden Vacancy". This field will not be included in the view screen, in order to keep it hidden.
    3. We insert post-function "Copy parsed text to a field" in the transition we determined in step 1. This post-function will be used to copy the value of Vacancy into Hidden Vacancy.
    4. Now, you can block any transition when Vacancy is different from Hidden Vacancy. To do it you can use "Boolean validator with math, date-time or text-string terms" with a boolean expression like %{aaaaa} = %{bbbbb}, where aaaaa is field code for Vacancy, and bbbbb is field code for Hidden Vacancy.
  4. Fidel Castro Armario repo owner

    "Hidden Vacancy" is an ordinary text field.

    You shouldn't include "Hidden Vacancy" in any screen. We only want it to store a value, not to be shown anywhere.

    You should follow my instructions step by step.

    Please, let me know if you have any other doubt.

  5. MAG-II reporter

    I followed your instructions (I think) correctly. It seems my problem is very close to being solved. I crated a text custom field called Hidden Vacancy. I added that custom field to the create issue screen, but I did not configure it to the screen. So you can't see the Hidden Vacancy on the create Issue screen. I added the Post Functions and Validator (see screenshot).

    What's happening now is that I am getting the workflow error message when I try to transition the Issue, whether I change my (original) Vacancy field or not. The idea is that I am hoping to get this workflow error message when I change the Vacancy field, in the Edit Issue screen. Again, I feel like I am very close to getting this problem resolved.

    Post Function.png

    Validator.png

  6. Fidel Castro Armario repo owner

    Hi @michaelgayheart,

    You should select Hidden Vacancy as Target field in "Copy parsed text to a field" postfuntio, and field code for Vacancy in parameter Text to be parsed....

    Fix your configuration, and let me know whether it solves the problem.

  7. MAG-II reporter

    I switched Vacancy and Hidden Vacancy around in the post function - still the same situation. Not able to transition when I do not edit the Vacancy Field.

    Hidden Vacancy is a text custom field. Only associated with the Create Issue Screen. It's not configured to the screen, so the user cannot see it. Maybe there's some kind of problem with my Hidden Vacancy custom field?

    Post Function 2 .png

  8. Fidel Castro Armario repo owner

    @michaelgayheart,

    You can't insert the post-function and validator in a same transition. You should insert the post-function in a transition where you capture the rightful value of Vacancy into custom field Hidden Vacancy, and then you use the validator to block following transitions of the workflow in case Vacancy has not the same value as Hidden Vacancy.

  9. MAG-II reporter

    Oh ok. This idea might not solve the problem I am having then. The idea is that the user transitions the Issue throughout the workflow, and at any random time can decide when to change the Vacancy field - that's when I want the block to happen. I was hoping to have this action be able to happen at any given moment in the workflow.

    If this concept is not possible, then no worries. Regardless, I appreciate your meticulous attention here.

  10. MAG-II reporter

    Oh wait - Maybe I misunderstood. It seems that I can put the Post function on the first transition. Then I am able to transition the Issue when I do not edit Vacancy. Then if I put just the Validator on the next transition I am able to transition if Vacancy is not changed, and not able to transition if Vacancy is changed. So this would mean if I put just the Validator on every other transition in the workflow then it should work.

    Does that sound right?

  11. Fidel Castro Armario repo owner

    We can use the following approach:

    1. Create screen called "Screen for Vacancy Edition", with only field Vacancy.
    2. Create a global reflexive transition called "Edit Vacancy", and associate screen Screen for Vacancy Edition" to it. Global transitions are available from any status, and reflexive transitions doesn't change issue status. This is an example of creation of one of these transitions:global-reflexive-transition.png
    3. Add "Copy parsed text to a field" post-function to transition "Edit Vacancy" with the configuration needed to copy Vacancy into Hidden Vacancy.
    4. Now use the following boolean validator in all the transitions you want to block in case Vacancy has been edited: %{nnnnn} = null where nnnnn is field code for Hidden Vacancy.
    5. Remove field Vacancy from EDIT screen. If you are using the same screen for EDIT and VIEW operations, then you have to split it into two screens, one for each operation.

    If you need to inhibit transition "Edit Vacancy" in some statuses, you can use "Boolean condition with math, date-time or text-string terms" with the following boolean expresion: %{00016} not in ["Open", "Reopened", "New"], assuming that those are the names of the statuses you don't want transition "Edit Vacancy" to be available.

  12. MAG-II reporter

    Fidel - This is great stuff. You have single handedly solved my problem once again. Your first suggestion works just fine for now, and I will absolutely explore that alternative that you just sent above.

    As always, thank you for your hard work and attention. If there's anything I can do on my end then please let me know. Thanks!

  13. Log in to comment