Show warning on transition for late issue.

Marian Gebauer October 3, 2019

Hello Community

 

I am new to JIRA and coding. Spent same time on searching for some relevant information how could i achieve my goal. What i want to do is to show warning on transition to resolve state and compare two date to determinate that issue is late. Compare like Delivery date is less then Resolution date Updated and then show warning that user can ok or (X). So far i have only manage to show util.UserMessageUtil with warning that they are closing late issue but wasn't able to conditionally show it based on my previous requirement(Delivery date is less than Resolution date) .

 

Thank you 

2 answers

0 votes
Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 3, 2019

Hi again,

This code should help out.

 

import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def flag = [
type: "warning", //Other possible options are "info", "success", "error"
body: "You are closing late issue.",
]

def dateCustomField = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectsByName("Delivery Date")[0])
def resolutionDate = issue.resolutionDate
def updatedDate = issue.updated

if(dateCustomField < resolutionDate){
UserMessageUtil.flag(flag)
log.warn('Condition True')
}

 

However if you would like to show a yes/no warning, this is not the way to do it.

Maybe you could run this check in a transition Validator. And for the yes/no part, you could include a custom field "Override" and check if that is "Yes" then skip the condition, else throw warning.

 

Cheers

Marian Gebauer November 6, 2019

Hello Gezim

 

Sorry for late reply but had to do upgrade to new version of JIRA we are on 8.3.3.

Thanks for suggestion but it didn't work for me. I am getting error Static type checking Cannot find matching method java.lang.Object#compareTo...

 

It is in line 15 which is if (dateCustomField < resolutionDate)

 

Any suggestions?Error in code.png

Marian Gebauer May 26, 2020

Hello @Gezim Shehu [Communardo] 

 

I have tested your solution but dint seems to work on that field. That pop up messages is displayed every time even when conditions isn't true. It seems that comparing part isn't working .

 

Thank you 

0 votes
Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 3, 2019

Can you share what you've come up with so far?

Maybe we could see and help out in that part by adding a conditional check.

Marian Gebauer October 3, 2019

Hello Gezim

Thank you for  your reply.

import com.onresolve.scriptrunner.runner.util.UserMessageUtil
def flag = [
type: "warning", //Other possible options are "info", "success", "error"
body: "You are closing late issue.",
]
UserMessageUtil.flag(flag)

 

So far i have this 

Suggest an answer

Log in or Sign up to answer