Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,360,454
Community Members
 
Community Events
168
Community Groups

JIRA script runner and Automation for JIRA

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