Traying to set Due date as per Priority

Rakesh Jajper
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 15, 2022

Can anyone help, trying to set due date as per priority but i Cant look like I am missing how to declare mutable issue, priority and Due date

 

Trying to do this in Behavior

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
//import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.option.Option
import groovy.time.*
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import java.sql.Timestamp;

def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

MutableIssue mutableIssue = issueManager.getIssueObject(issue?.id)
//import com.opensymphony.workflow.InvalidInputException
//import java.sql.Timestamp;
//import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY

//def issueManager = ComponentAccessor.getIssueManager()
//MutableIssue mutableIssue = (MutableIssue) issue;
//def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def priority = getFieldById("priority")
def env = getFieldByName('Environment')
//def priorityvalue = priority.value as List
def dateToSet = getFieldByName("Due Date")
def setDueDate = mutableIssue.getDueDate();
//MutableIssue mutableIssue = issueManager.getIssueObject(issue?.id);
//MutableIssue mutableIssue = (MutableIssue) issue;
//def priority1 = mutableIssue.getPriority().getString("name");
//def setDueDate = mutableIssue.getDueDate();
//def priority1 = customFieldManager.getPriority().getName()

//MutableIssue mutableIssue = issueManager.getIssueObject(issue.id);

//def priorityField = mutableIssue.priority
//def dateToSet = null
dateToSet.setHelpText("Required")
env.setHelpText("Required")
if (priority == "Blocker") {
dateToSet = new Date() + 1
} else if (priorityvalue == "Critical") {
dateToSet = new Date() + 5
} else if (priorityvalue == "Major") {
dateToSet = new Date() + 20
} else if (priorityvalue == "Medium") {
dateToSet = null
} else if (priorityvalue == 'Minor') {
dateToSet = new Date() + 90
}
// Set date
//mutableIssue.setDueDate(dateToSet)

// Update issue
//issueManager.updateIssue(user, mutableIssue, EventDispatchOption.ISSUE_UPDATED, false)

1 answer

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 16, 2022

Hi @Rakesh Jajper , welcome on the community. First question... do you need to use behaviors? Does your user need to view the due date on the screen?

Because if the user does not need it, you can set it using postfunction.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events