It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

script runner duration field Edited

Hello I need to make field like a SLAs field in SD in JIra.
This field have to change the value depend on time spending and type of priority.

Blocker –  15m, 8h

High – 30m, 15h

Medium – 1d, 32h

Low – 1d, 40h.

if priority is blocker the reaction time should show 8h 15 min from create (change) the issue.

how can I do it using script runner filed

Screen Shot 2020-05-20 at 17.17.13.png

1 answer

0 votes

You can try something like this:

import groovy.time.TimeDuration
def map = [
Blocker : new TimeDuration(0,8,15,0,0),
High : new TimeDuration(0,15,30,0,0),
Medium: new TimeDuration(1,32,0,0,0),
Low: new TimeDuration(1,40,0,0,0)
]
def duration = map[issue.priority.name]
(duration) ? duration.toMilliseconds()/1000 as Long : null

The TimeDuration constructor is: TimeDuration​(int days, int hours, int minutes, int seconds, int millis)

And the Jira duration fields expects a number of seconds as Long

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

How Forge helped scale Smart Links

Hi Community! Forge is our new cloud app development platform – now, developers can build trusted, scalable apps in minutes without the need to manage infrastructure or security. Forge is currently...

147 views 0 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you