Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,463,883
Community Members
 
Community Events
176
Community Groups

Traying to set Due date as per Priority

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

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

Atlassian Community Events