Dear community,
I am currently migrating from Server to Cloud and I do have some groovy based post functions, which I need to translate into Nunjucks.
I need to read some values from a custom field and use it in nunjucks, to do some if/else logic. How do I do that?
I have the Repeating Issue App by codedoers. In Server, there is a specific field with the "Next occurrence", in Cloud this field is missing. I have asked support and they told me, that I can access the information via "com.codedoers.jira.repeating-issues:task".
I am using the JMWE-app for development.
If I use a "Jira expression", I can get the needed information:
issue.properties['com.codedoers.jira.repeating-issues:task']
results in
Your Jira expression ran successfully
Result:
"Object":{
"updatedTime":
"2023-01-20T07:11:47Z"
"updatedBy":
"60815edd9c4625006b35804a"
"action":
"WorkflowStepTask"
"lastExecutionErrors":[]
"recurrenceRules":[
0:"RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=20"
]
"nextOccurrenceTime":
"2023-02-20T06:41:54Z"
}
issue.properties['com.codedoers.jira.repeating-issues:task'].recurrenceRules[0]
results in
Your Jira expression ran successfully
Result:
"RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=20"
If I try to use this in Nunjucks expression, I am not getting anything back.
{{ issue.properties['com.codedoers.jira.repeating-issues:task'].recurrenceRules[0] }}
It just says "Your template ran successfully". No result.
Any help is very much appreciated.
Chris
This is, how to get the data:
{{ issue | issueProperty("com.codedoers.jira.repeating-issues:task") | dump(2) }}
{{ issue | issueProperty("com.codedoers.jira.repeating-issues:task") | field("nextOccurrenceTime") }}
{{ issue | issueProperty("com.codedoers.jira.repeating-issues:task") | field("recurrenceRules") }}
the last will return
RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=20
How do I extract "MONTHLY" from this?
Or how do I test, if this string contains "MONTHLY"?
I gave this a go as well and seems you need to convert the output to a simple string (looks like the "dump" creates an object, which does not seem to play nicely with the "IN" operator we need to check for the substring).
see example for MONTHLY below with the string conversion added at the end.
Keep in mind that
a) I am not a dev so take my approach with a grain of salt :) and
b) the search is case-sensitive (see here for a workaround: How to check whether the substring is present in a string in Nunjucks Template - Stack Overflow)
Fingers crossed it works for your case and kind regards
Fabian
{% if 'MONTHLY' in issue | issueProperty("com.codedoers.jira.repeating-issues:task") | field("recurrenceRules") | string %}
true
{% else %}
false
{% endif %}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is, how you do it:
{% set res = issue | issueProperty("com.codedoers.jira.repeating-issues:task") %}
{% set nOTime = res | field("nextOccurrenceTime") %}
nOTime: {{ nOTime }}
{% set recurrenceRules = res | field("recurrenceRules") %}
{% if recurrenceRules %}
{% set rR = recurrenceRules.toString() %}
{% set freq = rR.match(r/FREQ=(\w{0,50})/)[1] %}
freq: {{ freq }}
{% set interval = rR.match(r/INTERVAL=(\w{0,50})/)[1] %}
interval: {{ interval }}
{% endif %}
full credit to @Suprija Sirikonda _Appfire_
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.