You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi Experts
Need help.....!
Using behavior script- trying to achieve below
Need to Get value of Custom date field and then need set new value(10 days from the date selected in custom field) in Due Date field.
For example
Custom field Datefield selected as 26/Feb/2021
The in DUE DATE, need to set (10+(datefield Value)). So due date would be 7/Mar/2021
Can please help with logic and script.
Hi there,
You may use the script below;
Please do not forget to change the cf ID and username for the operation before use it.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.core.util.DateUtils
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.user.ApplicationUser
import java.text.SimpleDateFormat
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def issueManager = ComponentAccessor.getIssueManager()
def issue = underlyingIssue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
MutableIssue mTarget = (MutableIssue) issue
JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext()
authContext.setLoggedInUser(ComponentAccessor.getUserManager().getUserByName("admin")) //type username for change operation
ApplicationUser automationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def dateFieldCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11998") //type cf id of the date field
def dateFieldValue = issue.getCustomFieldValue(dateFieldCF).toString()
def newDate = new SimpleDateFormat("dd.MM.yyyy").format(dateFieldValue).plus(10)
mTarget.setCustomFieldValue(dateFieldCF, newDate)
issueManager.updateIssue(automationUser, mTarget, EventDispatchOption.DO_NOT_DISPATCH, false)
Best Regards,
Burak
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.