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

JMWE - Post function conditional Execution based on SLA being active

Stephen Dyball February 20, 2024

Hello!

This is a strange one to word, so apologies if it makes zero sense!

I am working on creating a post-function that sends a comment in a request, but I only want the comment to be posted if no SLA is active (The SLA information is "Due Date" or customfield_13779)

I have tried various iterations of: {{issue.fields.customfield_13779.completedCycles.breachTime == NULL}} and {{issue.fields.customfield_13779.remainingTime == NULL }} and {{issue.fields.customfield_13779.remainingTime.friendly > 1m }}

But had no luck so far as the nunjucks always returns True, regardless of SLA being active or not, so I'm clearly looking at this at the wrong angle. I have taken a dump of the field while the SLA is active vs when it is inactive:

Active SLA

"id": "243",
"name": "Due Date",
"_links": {
"self": "https://jirajirajirajira.atlassian.net/rest/servicedeskapi/request/415715/sla/243"
},
"completedCycles": [],
"ongoingCycle": {
"startTime": {
"iso8601": "2024-02-19T15:35:29+0000",
"jira": "2024-02-19T15:35:29.174+0000",
"friendly": "Yesterday 3:35 PM",
"epochMillis": 1708356929174
},
"breachTime": {
"iso8601": "2024-03-04T15:35:29+0000",
"jira": "2024-03-04T15:35:29.174+0000",
"friendly": "04/Mar/24 3:35 PM",
"epochMillis": 1709566529174
},
"breached": false,
"paused": false,
"withinCalendarHours": true,
"goalDuration": {
"millis": 288000000,
"friendly": "80h"
},
"elapsedTime": {
"millis": 8508034,
"friendly": "2h 21m"
},
"remainingTime": {
"millis": 279491966,
"friendly": "77h 38m"

Inactive SLA

"id": "243",
"name": "Due Date",
"_links": {
"self": "https://ocadosupport-sandbox-587.atlassian.net/rest/servicedeskapi/request/415716/sla/243"
},
"completedCycles": []

 

Any help would be greatly appreciated!

Kind Regards,

Ste

1 answer

1 accepted

1 vote
Answer accepted
Reshma Begum _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2024

Hi @Stephen Dyball ,

Please add a conditional execution as below:

{{issue.fields.customfield_13779.ongoingCycle != null}}

To check if the SLA is active. 

Hope this helps!

Thanks,

Reshma 

Stephen Dyball February 20, 2024

Hey @Reshma Begum _Appfire_ 

Thank you for this - worked a treat! I just had to change this over to "== null" for my use case - you've saved me a headache! :) 

 

Thanks again!

Ste

Like Reshma Begum _Appfire_ likes this

Suggest an answer

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

Atlassian Community Events