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

JIRA script runner and Automation for JIRA

Pawel September 9, 2020

Hi, I have a problem, why is the scrypt that works on postfunction not working in automation for JIRA? Can someone explain why it doesn't work?

----CODE----

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
import java.sql.Timestamp

def issueManager = ComponentAccessor.getIssueManager()

def cfDate = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12018") // date custom field
def cfCyklic = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12019") // select custom field
def dateFieldValue = issue.getCustomFieldValue(cfDate)
def cfCyklicValue = issue.getCustomFieldValue(cfCyklic)
def selectedOption = ((LazyLoadedOption)cfCyklicValue).getValue ()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser ()

def date = Calendar.getInstance()
if (selectedOption.equals ("miesięczna")){
// if miesięczna selected add 1 month
date.add(Calendar.MONTH, 1)
} else if (selectedOption.equals ("kwartalna")){
// if kwartalna selected add 2 month
date.add(Calendar.MONTH, 3)
} else if (selectedOption.equals ("półroczna")){
// if kwartalna selected add 2 month
date.add(Calendar.MONTH, 6)
} else if (selectedOption.equals ("roczna")){
// if kwartalna selected add 2 month
date.add(Calendar.MONTH, 12)
}
issue.setCustomFieldValue(cfDate, new Timestamp(date.getTimeInMillis()))
//sue.setCustomFieldValue(cfDate, Date.from(date.toInstant()))
//issue.setCustomFieldValue(cfDate, new Date(date.getTime()))
//issue.setCustomFieldValue(cfDate, date.toInstant())
//issue.setCustomFieldValue(cfDate, date )
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)

 

1.PNG2.PNG3.PNG4.PNG

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events