Clear Due Date field while cloning using scriptrunner

Sid August 29, 2018

I am trying use script runner to clear the Due Date field when an issue is cloned so that the new issue does not have the old issue's Due Date. 

I used a custom script post function to clear the field. The script runs fine but still would not clear the Due Date field. 

Can someone suggest any alternatives or point what I'm doing wrong?

The code I'm using: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import webwork.action.ActionContext
import java.sql.Timestamp

def fieldManager = ComponentAccessor.getFieldManager()
def linksSystemField = fieldManager.getField("issuelinks") as IssueLinksSystemField
def request = ActionContext.getRequest()
if (request) {
def params = request.getParameterMap()
def issueLinkingValue = linksSystemField.getRelevantParams(params) as IssueLinksSystemField.IssueLinkingValue

if ( (issueLinkingValue.linkDescription == "is cloned by" )) {
issue.setDueDate(null)

}

}

 

Thanks

 

1 answer

0 votes
Mark Markov
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.
August 29, 2018

Hello @Sid

It is very strange code, but lets try to store changes with issueManager.update issue

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import webwork.action.ActionContext
import java.sql.Timestamp

def fieldManager = ComponentAccessor.getFieldManager()
def linksSystemField = fieldManager.getField("issuelinks") as IssueLinksSystemField
def request = ActionContext.getRequest()
if (request) {
def params = request.getParameterMap()
def issueLinkingValue = linksSystemField.getRelevantParams(params) as IssueLinksSystemField.IssueLinkingValue

if ( (issueLinkingValue.linkDescription == "is cloned by" )) {
issue.setDueDate(null)
ComponentAccessor.getIssueManager().updateIssue(issue.getAssignee(), issue, EventDispatchOption.ISSUE_UPDATED, false)

}

}

 And see what happens :)

Sid August 29, 2018

Thanks for the quick reply Mark. 

Used the code you provided but the Due Date field is still copied :(

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events