Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JMWE set issue field from another field (SLA calculation)

Jennifer Marple
Contributor
June 14, 2024

Hi - I'm working on migrating many native JSM automations (which were configured by a predecessor of mine - so I don't always have the context) into JMWE. I have one still relatively high use rule that I haven't yet figured out how to properly configure in JMWE.

 

The automation appears relatively simple. It's running hourly, and editing an issue field called "Response SLA Time". That field appears to be just a calculation of how long it took to make first response on an issue (but it factors in whatever SLA rules are configured, to discount weekends/off work hours, etc).

The native JSM automation just has this as the value to set:

{{time to first response.completedCycles.elapsedTime.friendly}}

 

The field "time to first response" is a count down, showing how much time remains on the SLA. So, say the priority/project/organization on the issue warrants an 8 hour SLA, this value starts at 8, and goes down to 0 and then into the negatives if the SLA is exceeded (also that count down pauses whenever outside of the defined business hours as applicable per SLA). 

The field "Response SLA Time" is calculating the inverse of that time to first response. So for instance, if "time to first response" is 7:50, that means the case was responded to in 10 minutes, and the old automation would populate "Response SLA Time" with "10m".

This new value is in turn being used in some reports and fed to extracts that populate some dashboards and other visualizations about SLA attainment and such.

 

How do I translate:

{{time to first response.completedCycles.elapsedTime.friendly}}

into something JMWE can use in the Set Issue Fields post function for the field "Response SLA Time"?

1 answer

1 accepted

2 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2024

Hi @Jennifer Marple 

have you tried this?

{{issue.fields["time to first response"].completedCycles.elapsedTime.friendly}}

 

Jennifer Marple
Contributor
June 14, 2024

I hadn't, but tried it now.

It runs, and appears in the JMWE logs as INFO status, no failures noted, but doesn't appear to perform the expected update.

I have an "If Scope" Target issues JQL set in the JMWE Event-based action like this:

project = "The Actual Project in Question" AND "Response SLA time[Short text]" IS EMPTY AND reporter in (myself)

I tested that JQL in a filter separately, and the issue I'm using to test does come up as expected.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2024

Can you just "Test" the script using the "Test Nunjucks template" button while editing your event-based action against an issue that has a value for that "time to first response" SLA field?

Jennifer Marple
Contributor
June 14, 2024

Did try that, it responds just with: Your template ran successfully 

(no True or False as I've seen when testing other scripts)

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2024

Sorry, my bad, the syntax is:

{{ issue.fields['Time to first response'].completedCycles | last | field('elapsedTime.friendly') }}

Make sure you replace "Time to first response" with the exact name (case-sensitive) of the SLA field.

Like Jennifer Marple likes this
Jennifer Marple
Contributor
June 14, 2024

that looks promising! I got "4m" as my test result this time. Have it scheduled to run in about 5 minutes and we'll see if it catches this test case this time. Assuming so - I'll then remove the boundaries I put to keep it to just my test case.

Thank you @David Fischer !

Jennifer Marple
Contributor
June 14, 2024

Worked as expected on the schedule, thank you!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events