scriptrunner escalation service copy duedate to a custom field

ayala nayman June 8, 2020

hello , 

I'm very new to groovy and 

I would like help to write a groovyscript  that will copy the date in DUEDATE field to a custom field of date type.

1 answer

1 accepted

0 votes
Answer accepted
Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2020

Hi, @ayala nayman 

Something like this should do the trick:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser

MutableIssue issue = issue
ApplicationUser actor = ComponentAccessor.getUserManager().getUserByName("userNameWhoRunsTheScript")
CustomField dateField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("customFieldName")

issue.setCustomFieldValue(dateField, issue.getDueDate())
ComponentAccessor.getIssueManager().updateIssue(actor, issue, EventDispatchOption.ISSUE_UPDATED, false)
ayala nayman June 15, 2020

thanks a lot ! I used in  the escalation services of script runner works great :)

Suggest an answer

Log in or Sign up to answer