I’ve created a single script to calculate some time-to-SLA parameters ( - time to resolve, time to respond, Time to fix&Patch - ). Goal is to display accurate time-to-SLA values based on current date-time.
Currently for each SLA parameter a (script runner) scripted field has been created and linked with the script. As I’m already displaying 4 time-to-SLA parameters ( - and hence 4 scripted fields are linking to same script - ) I was wondering what’s the (best) approach to set multiple fields in single script ( - when ticket is viewed - )
I’ve been playing with a Script Runner Listener which I can use to set value of multiple fields in single script but data is not accurate as listener is only triggered during Issue Create, Issue Update, .. events. The time-to-sla parameters should be (re)calculated and set each time ticket is displayed. Tx!
I think I understand what you're trying to do. However, I am slightly confused. When you say each SLA parameter scripted field is "linked" to the single script that does the calculation, what is meant by this? How are they linked?
The core advantage of using script fields is that you can just place the script inside them to return a value, without using an outside method to set them (like a listener).
Why not just split up the single script into four different scripts, and place that code into their respective script fields?
Time to Resolve field
//place code in script field that does the Resolve calculation
//return the value
Time to Respond field
//place code in script field that does the Respond calculation
//return the value
And so on.
Yes, you'll have code repetition. But, you'll solve the problem of having outdated values. Script Fields will automatically recalculate their value whenever the issue is loaded.
Tx for your feedback! Correct – this is how I’ve got it implemented at the moment. 5 scripted fields have been created and each of them linked to their own script. Unfortunately there is a lot of code repetition and hence my question if there is a way to tweak this.
The reason to optimize this is twofold;
Is there any possibility to set multiple scripted fields via 1 single field ( - or this doesn’t exist yet - ) ?
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs