Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
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

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

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.
Jul 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