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
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.