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.
Hello,
I am trying to write a script for script runner behaviors for the request below;
If the Risk Level custom field is high, due date will be auto selected 7 days from ticket created
If the Risk Level custom field is medium, due date will be auto selected 30 days from ticket created
If the Risk Level custom field is low, due date will be auto selected 90 days from ticket created
I am not familiar with script writingas you can see and here is what I have came up with.
Could you please help me with it since it does not work?
def RiskLevelfield= getFieldByName("Risk Levels")
def DueDate = getFieldByName("Due Date")
def RiskLevel = RiskLevelfield.getValue() as RiskLevel
if (RiskLevel.name == "High") {
issue.setDueDate(new Timestamp((issue.dueDate + 7).time))
if (RiskLevel.name == "Medium") {
issue.setDueDate(new Timestamp((issue.dueDate + 30).time))
if (RiskLevel.name == "Low") {
issue.setDueDate(new Timestamp((issue.dueDate + 90).time))
}}}
else {
}
Thank you so much!
Create a behaviour on the "RiskLevel" field with the following server-side script:
def dueDateField = getFieldByName("Due Date")
def riskLevel = getFieldByName("Risk Levels").value
def dateToSet
if (riskLevel == "High") {
dateToSet = new Date() + 7
} else if (riskLevel == "Medium") {
dateToSet = new Date() + 30
} else if (riskLevel == "Low") {
dateToSet = new Date() + 90
}
dueDateField.setFormValue(dateToSet.format("dd/MMM/yy"))
I have tried this on a test project by using Priority field instead of Risk Level and it does not work. Please see the screen shot below. Do you see anything wrong it?
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Calling getValue() on the priority field actually returns a Priority object. So to use it like you want to you have to access its name property:
def priority = getFieldById("priority").value.name
Also, Im not sure why your field is called "Priority [System]", every time I've seen it was always just called "Priority"...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is what I have tried and still nothing. Any ideas why?
Thank you for your patience and understanding.
Elif
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also tried with a custom field called " SEVERITY" to see of it works. But it did not. Does it work on your system? We use Jira v7.11.2, not sure if that makes any difference.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That should definitely work...
Is your behaviour mapped to the correct project/issue types?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried to add conditions , no change. I change the severity on the ticket several times but no values are being assigned to " due date" . Please see below screen shots.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Elif Alverson (and to anyone else running into this issue), use getFieldByID("duedate"). Due Date is a Jira system field, so you need to pull it by its ID.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.