Hello guys,
I'm using Jira Service Desk Cloud and Script Runner and I need to copy the SLA value (Time to resolution) to a Jira Software project with a post function.
Which would be the best way to achieve this?
Hi Ricardo,
Thank you for your question.
I can confirm that the Time to resolution SLA is stored as a custom field on an issue which means that it is possible to get its value inside of a post function with ScriptRunner for Jira Cloud.
Your post-function script will need to make a call to the Issue rest API which Atlassian provide that is documented here, in order to get the service desk issue and its fields.
I can confirm we have an example of how to do this in the ScriptRunner Script Console page if you navigate to the examples section and click on the link named Get Issue Fields.
This will populate the console with some example code that you can use to return the service issue in order to see how the Time to resolution SLA is stored on it.
You will then be able to use this to see how you can extract the value out of this SLA field and to save this to a variable to use within your post-function script.
Once you have got the SLA value you will then need to make an update request to the Issue API to set the value in the field you require on an issue and I can confirm the example located here shows how to set a number field on an issue and the examples located here show how to set values in different types of fields.
You will be able to take all of the examples shown above and will be able to use these as a reference guide to help yourself to create the script that you require.
I hope this helps.
Regards,
Kristian
Kristian,
Thanks for reply.
I'm having problems to PUT the SLA Time to resolution information on a issue. There is any example of this PUT code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ricardo,
Thank you for your response.
Can I please clarify when you are trying to put the value on an issue what type of field are you trying to put in so that I can recommend a way of doing this?
I.E are you trying to set the Time to resolution field itself or would you want to put the value extracted from this field into a custom field which was a number field or a text field?
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kristian,
I'm tried this code:
fields: [
customfield_10066: 'Time to resolution'
]
//(customfield_10066 is the Time to resolution SLA field)
I'm trying to put the value extracted from this field into a custom field. Or using the same field in a Software project (I don't know if is possible)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ricardo,
I can confirm that you set the Time to resolution SLA field on a software project as the SLA fields are only permitted by Jira to used in Jira Service Desk Projects.
However, in your script, once you have extracted the value if you save it to a variable in your script as a String then you could set this value into a custom text field on the issue in the Software Project.
I can confirm the example located here shows how to set a value in a text field using the summary field as an example. This can be used as a reference guide to help you create the script that you require.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can also do this easily in JMWE for Jira Cloud, using the Nunjucks Tester to see the value of the SLA field. For example:
Then you can use a Set Field Value or Set Field Value of Linked Issues post function to copy some of this to a custom field. However, what you cannot do, for obvious reasons, is to copy the whole SLA field, as it would make no sense (the SLA field records what happens to an issue, so it's issue-specific).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David. Thank you for the answer!
I am looking for this option usinf JMWE cloud.
How do i copy the remaining time/breached time alone in a text field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @JiraAdmin
the RemainingTime is available through this:
{{issue.fields["Time to Resolution"].ongoingCycle.remainingTime}}
But it's in milliseconds so you might want to transform it into some more readable form. Also, note that it will become instantly obsolete since the remaining time changes every millisecond...
Likewise, the breached time is available through:
{{issue.fields["Time to Resolution"].ongoingCycle.breachTime.friendly}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think JSU for Cloud could do this :-)
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.