Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jira expression validator for a transition works during test but not in production

Martinez_ Diego April 2, 2024

Hello, when a user closes an issue and chooses either the complete, done, or fixed resolution, the time tracking field should not be empty. I don't want to require that field when the resolution is anything else, like clone, won't fix, duplicate.

 

I can pass this when testing the expression but when I attempt to test it on a real issue, the error message will not show up.

Tried:

issue?.timeSpent == null &&
issue?.resolution?.name == "Complete"

 

Also tried: 

['Complete','Fixed','Done'].includes(issue?.resolution?.name) && issue?.timeSpent == null

Field that I want to not be empty: Screenshot 2024-04-02 100950.png

Screenshot 2024-04-02 100904.png

3 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Martinez_ Diego April 2, 2024

I was able to get it to work using the resolution IDs below but now the validation shows up for every resolution selected

issue?.timeSpent == null &&
issue?.resolution?.id == 6 && 1 && 10000

Nacho Moreno Ortega April 8, 2024

Hi @Martinez_ Diego ,

Could you try the following expression? In this case, the transition will not be performed (it will return false) if the timeSpent is null and the resolution is one of the mentioned.

issue?.timeSpent == null && (issue?.resolution?.id == 6 || issue?.resolution?.id == 1 || issue?.resolution?.id == 10000) ? false : true

Is this the expected behavior?

If not, feel free to contact us via our Support Service Desk.

Best regards,

Nacho

Like Martinez_ Diego likes this
Martinez_ Diego April 12, 2024

@Nacho Moreno Ortega This worked! Thank you, it should return false so the user can input time spent if it is not there. When it comes to the colon syntax, can you show me where that is in the JWT notes? 

Nacho Moreno Ortega April 15, 2024

Hi @Martinez_ Diego ,

I'm glad that it has worked!

You can find information about the corresponding operator in the section "Conditional operator" on the following page of our documentation: Operators 

If you need anything else regarding our applications, please do not hesitate to contact us.

Best regards,

Nacho

1 vote
Vicente Domínguez _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 2, 2024

Hello @Martinez_ Diego

I am part of the Decadis team and I would like to help you with this JWT for Jira Cloud configuration.

The problem here could reside in the part of the expression that evaluates the time logged in the transition screen.  We elaborated the use case Validate worklogs with some relevant expressions for this purpose that could be useful here.

Could you try with the following expression? It should make logging work in the transition screen required if any of the resolutions Done, Complete or Fixed is set.

!["Done", "Complete", "Fixed"].includes(issue?.resolution?.name) || (issue?.timeSpent||0) > (originalIssue?.timeSpent||0)

Please, do not hesitate to contact us in this thread or via our Support Service Desk or visit our documentation if this does not resolve your problem.

Best regards,

Vicente

Martinez_ Diego April 3, 2024

Hi @Vicente Domínguez _Decadis AG_ I tried that and it works for all of the resolutions but the three in the expression. When I add a time in the time tracking field and try to complete the request, it still shows the same error message and when I test it out, it gives the error below, any thoughts?

 

Screenshot 2024-04-03 113629.png

Vicente Domínguez _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2024

Hello @Martinez_ Diego,

For some reason, I can not reply to you comment from yesterday directly. I hope that this is not a problem.

The operator "||" has been replaced with ">" in the expression of the screenshot. Does the configuration work if you use the expression that I originally provided without any change?

Please, note that the context "originalIssue" can only be evaluated during a transition, so testing this expression in our expression editor could return an error due to the unavailable context.

Please, let us know if it works after the change.

Best regards,

Vicente

 

Martinez_ Diego April 4, 2024

@Vicente Domínguez _Decadis AG_ 

Apologies on the screenshot, the formula still does not work when I add an actual time spent value to the time tracking field and try to close out the issue with one of the three listed Resolutions (Done, Complete, Fixed). It does work the other way around, I do need a value for those three resolutions and I don't need to enter a value for the other resolutions.

Screenshot 2024-04-04 103118.pngScreenshot 2024-04-04 103045.pngScreenshot 2024-04-04 103031.png

0 votes
Vicente Domínguez _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2024

Hello @Martinez_ Diego,

If the time does not need to be logged during the transition because the Log Work field is not included in the transition screen, but before the transition is executed, the expression should be a bit different.

let wk = issue.worklogs;
!["Done", "Complete", "Fixed"].includes(issue?.resolution?.name) || (wk != [] && wk[wk.length-1].timeSpent > 0)

This expression evaluates if time was ever logged in the transitioned issue while the previous one evaluates if time was logged in the transition.

Does it work for you?

Best regards,

Vicente

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events