I have one script field called "Warranty Date Status" its value returns in HTML format( Valid or Invalid),depending on these values i have to make auto transition from status "INPROGRESS" TO "VALID DATE" or "INVALID DATE".
Could You please help me out for this?
I have tried with Toolkit plugin but didn't work.
It depends how the value of scripted field changes. Either you fire a custom event upon value set OR configure a Escalation service which will run in intervals to check the value and runs a script which transitions the issue.
Have a look IssueService class for triggering the transition from script. I will try to make a script when I have time :)
IssueService.TransitionValidationResult
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
def warrantyField = customFieldManager.getCustomFieldObjectByName("Valid Warranty Date")
def warranty = issue.getCustomFieldValue(warrantyField)
def systemDate = new Date()
if(warranty == null){
return("<p style=color:blue>Please Enter Valid Warranty Date</p>")
}else if(warranty < systemDate)
{
return("<p style=color:red>INVALID</p>")
}else
{
return("<p style=color:green>VALID</p>")
I have this code in script field based on these values i need to transit status automatically from "IN PROGRESS" to "VALID DATE" or "INVALID DATE".
could we able to do this using listener or not plz let me know if possible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suhas,
Could you plz help me in this issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think in the same script you can put code in IF statement to transition the issue. Transition issue code looks like this.
Try following code. Use respective transition ids in both if statements. You can find transition IDs in transition name. they are written in brackets (11) like this.
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def warrantyField = customFieldManager.getCustomFieldObjectByName("Valid Warranty Date")
def warranty = issue.getCustomFieldValue(warrantyField)
def systemDate = new Date()
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setSkipScreenCheck(true)
}
if(warranty == null){
return("<p style=color:blue>Please Enter Valid Warranty Date</p>")
def validationResult = issueService.validateTransition(user, issue.id, transitionID, issueInputParameters) //actionID is transition id, you can see it in the workflow
if (validationResult.isValid()) {
// Perform the transition
def issueResult = issueService.transition(user, validationResult)
}
}else if(warranty < systemDate)
{
return("<p style=color:red>INVALID</p>")
def validationResult = issueService.validateTransition(user, issue.id, transitionID_2, issueInputParameters) //actionID is transition id, you can see it in the workflow
if (validationResult.isValid()) {
// Perform the transition
def issueResult = issueService.transition(user, validationResult)
}
}else
{
return("<p style=color:green>VALID</p>")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have tried but not working.
I have tried with script listener but not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its syntax errors I guess. have you tried adding those missing brackets { s? I have updated now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yaa i have tried with adding those brackets { but not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
def warrantyField = customFieldManager.getCustomFieldObjectByName("Valid Warranty Date")
def warranty = issue.getCustomFieldValue(warrantyField)
def systemDate = new Date()
return warranty > systemDate
Could you make transition for this?
Value returns true or false boolean values.
if it returns true the transition validate date(21) action id has to perform else invalidate(31) action id has to perform.
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.