Write field on issues returned by JQL query

Issue #188 resolved
Shai Dahan created an issue

Hello Fidel,

I would like to know if I can use this type of post function for the following scenario:

We have exactly 50 issues in a specific project that contain a value of a custom field called "BI Project Rank" each issue has a different value between 1 to 50. The JQL for these issues is:

project = "BI New" AND "BI Project Rank" is not EMPTY ORDER BY cf[15004] ASC

Now, we want to create a post function which will change the value of this custom field according to its ranking.

i.e. if you change the ranking of issue number 40 to number 5, all the ranking of issues below number 5 need to be changed accordingly:

issue 5 need to be changed to 6

issue 6 need to be changed to 7

issue 6 need to be changed to 7

.

.

issue 49 need to be changed to 50

There shouldn't be any 2 issues with the same ranking

Could you let me know if this is feasible?

Thanks,

Shai

Official response

  • Fidel Castro Armario repo owner

    Hi Shai,

    I have made available version 2.2.2_beta_6. With this version you can implement your requirements as I explain now:

    1) Remove "BI Project Rank" custom field from edit screen.

    2) Create a screen "Edit/Set BI Project Rank" which only contains "BI Project Rank" custom field.

    3) In statuses where you want to make possitble "BI Project Rank" custom field setting or edition, you should add the following 2 reflexive transitions: "Edit BI Project Rank" and "Set BI Project Rank". Reflexive means that they have the same origin and destination statuses, having the only purpose of displaying a screen.

    4) Add "Boolean condition with math, date-time or text-string terms" to transition "Edit BI Project Rank" with the following configuration:

    conf-0.png

    Boolean expression is:

    {11900} != null
    

    Note that {11900} is code for numeric value of custom field "BI Project Rank" in my particular JIRA instance. Use the corresponding field value in your instance. Do it also in the rest of conditions and post-functions that follow.

    5) Add "Boolean condition with math, date-time or text-string terms" to transition "Set BI Project Rank" with the following configuration:

    conf-1.png

    Boolean expression is:

    {11900} = null OR hasChanged({11900})
    

    6) Add "Boolean validation with math, date-time or text-string terms" to transitions "Edit BI Project Rank" and "Set BI Project Rank" with the following configuration:

    conf-4.png

    Boolean expression is:

    {11900} >= 1 AND {11900} <= 50 
    

    7) Add post-function "Write field on issues returned by JQL query" to transition "Edit BI Project Rank" with the following configuration:

    conf-2.png

    Parameter "Source value that will be written into target field" has value:

    {11900} > previousValue({11900}) ? (^{11900} > previousValue({11900}) AND ^{11900} <= {11900} ? ^{11900} - 1 : ^{11900}) : (^{11900} >= {11900} AND ^{11900} < previousValue({11900}) ? ^{11900} + 1 : ^{11900})
    

    Parameter "JQL Query" has value:

    project = "CRM" AND "BI Project Rank" is not EMPTY AND issuekey != %{00015} 
    

    Replace "CRM" with the key of project "BI New".

    8) Add post-function "Write field on issues returned by JQL query" to transition "Set BI Project Rank" with the following configuration:

    conf-3.png

    Parameter "Source value that will be written into target field" has value:

    ^{11900} >= {11900} AND ^{11900} < 50 ? ^{11900} + 1 : (^{11900} = 50 ? null : ^{11900})
    

    Parameter "JQL Query" has value:

    project = "CRM" AND "BI Project Rank" is not EMPTY AND issuekey != %{00015} 
    

    Replace "CRM" with the key of project "BI New".

Comments (16)

  1. Fidel Castro Armario repo owner

    Hi Shai,

    Currently it's not possible to do it, but it's possible to extend the functionality of some post-functions in order to make it possible.

    I have some questions to do:

    1. In you example issues whose ranking should be incremented are those with rankings from 5 to 39. Issues with ranking from 41 to 50 should remain unchanged. Isn't it?

    2. In order to make it possible to implement this behavior, "BI Project Rank" custom field should be removed from edit screen, and added to one or more transitions screens, in order to ensure that this field is only edited in transition screens. Is this requirement admisible for you?

    3. Is cf[15004] the same field as "BI Project Rank"?

  2. Shai Dahan Account Deactivated reporter

    Hello Fidel,

    1) Correct

    2) I don't have a problem with that, however if we want to add a non ranked issue to these 50 issues, we will have to set it somewhere (can this be done is a transition screens?)

    in addition if we add a non ranked issue for example to number 47 than:

    issue 47 need to be changed to 48

    issue 48 need to be changed to 49

    issue 49 need to be changed to 50

    issue 50 need to be cleared

    3) Correct

  3. Fidel Castro Armario repo owner

    When you say that "to add a non ranked issue", do you mean to set field "BI Project Rank"?

    In affirmative case, you could use the same transition(s) as you would use for editing the this field.

  4. Shai Dahan Account Deactivated reporter

    Correct, predominately for new issues which need to be ranked

    The last ranked issues should be removed from the list by clearing their field value "BI Project Rank

  5. Fidel Castro Armario repo owner

    Ok, I've got it. I will study the convenience of the extended feature, and will keep you informed. Perhaps in a 2 o 3 weeks I could have beta version, since at this moment the "forge" is occupied with other works.

  6. Fidel Castro Armario repo owner

    Sorry, Shai. Bitbucket doesn't allow me to do it. You will have to tell Mike to log in, and click on the button to watch the issue.

  7. Fidel Castro Armario repo owner

    Hi Shai,

    I have made available version 2.2.2_beta_6. With this version you can implement your requirements as I explain now:

    1) Remove "BI Project Rank" custom field from edit screen.

    2) Create a screen "Edit/Set BI Project Rank" which only contains "BI Project Rank" custom field.

    3) In statuses where you want to make possitble "BI Project Rank" custom field setting or edition, you should add the following 2 reflexive transitions: "Edit BI Project Rank" and "Set BI Project Rank". Reflexive means that they have the same origin and destination statuses, having the only purpose of displaying a screen.

    4) Add "Boolean condition with math, date-time or text-string terms" to transition "Edit BI Project Rank" with the following configuration:

    conf-0.png

    Boolean expression is:

    {11900} != null
    

    Note that {11900} is code for numeric value of custom field "BI Project Rank" in my particular JIRA instance. Use the corresponding field value in your instance. Do it also in the rest of conditions and post-functions that follow.

    5) Add "Boolean condition with math, date-time or text-string terms" to transition "Set BI Project Rank" with the following configuration:

    conf-1.png

    Boolean expression is:

    {11900} = null OR hasChanged({11900})
    

    6) Add "Boolean validation with math, date-time or text-string terms" to transitions "Edit BI Project Rank" and "Set BI Project Rank" with the following configuration:

    conf-4.png

    Boolean expression is:

    {11900} >= 1 AND {11900} <= 50 
    

    7) Add post-function "Write field on issues returned by JQL query" to transition "Edit BI Project Rank" with the following configuration:

    conf-2.png

    Parameter "Source value that will be written into target field" has value:

    {11900} > previousValue({11900}) ? (^{11900} > previousValue({11900}) AND ^{11900} <= {11900} ? ^{11900} - 1 : ^{11900}) : (^{11900} >= {11900} AND ^{11900} < previousValue({11900}) ? ^{11900} + 1 : ^{11900})
    

    Parameter "JQL Query" has value:

    project = "CRM" AND "BI Project Rank" is not EMPTY AND issuekey != %{00015} 
    

    Replace "CRM" with the key of project "BI New".

    8) Add post-function "Write field on issues returned by JQL query" to transition "Set BI Project Rank" with the following configuration:

    conf-3.png

    Parameter "Source value that will be written into target field" has value:

    ^{11900} >= {11900} AND ^{11900} < 50 ? ^{11900} + 1 : (^{11900} = 50 ? null : ^{11900})
    

    Parameter "JQL Query" has value:

    project = "CRM" AND "BI Project Rank" is not EMPTY AND issuekey != %{00015} 
    

    Replace "CRM" with the key of project "BI New".

  8. Shai Dahan Account Deactivated reporter

    Thank you very much Fidel, very impressive piece of work. I will give it a go on our Dev Jira instance and will let you know if I've succeeded.

  9. Shai Dahan Account Deactivated reporter

    Thank you Fidel for letting me know about the new version.

    I can confirm that you resolution is working as expected.

    This definitely worth one more recommendation in Atlassian Marketplace :)

  10. Fidel Castro Armario repo owner

    I'm glad to know it worked well for you, and thanks a lot for the recommendation.

  11. Shai Dahan Account Deactivated reporter

    Hello Fidel,

    I need to edit something here in the post-function.

    When I action "Edit BI Project Rank", I would like to be able to clear the value (meaning delete the rank which now have to be a value of 1 to 50), for example issue which have been closed.

    Now if the issue which I've cleared was ranked 5, all the rest of the issues below 5 need to step forward 1 position up:

    6 to 5

    7 to 6

    8 to 7

    .

    .

    .

    50 to 49

    Should I raise another issue or should we stick with this one?

  12. Log in to comment