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!
Hi Christof,
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?
For example:
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 - ) ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.