Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JMWE Create Issue Post Function Iterate through User Property to build value

Paul Alexander
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.
October 27, 2022

In JMWE, I have this functional template applied to a Create Issue post function for a standard issue type that creates multiple subtasks and assigns them based on named users in a projectRole. I cannot find a means to iterate through the members' User Properties to build the unique Summary.

Here is what I have that supplies the Summary:

(Testing): {{ issue.fields.summary }} - {{issue.fields.assignee | userProperty("dept")}}

In the Assignee value, I use this template to iterate through the list.

{{it}}

In the multi-issue creation block, I supply this template which builds the member list for each assignee.

{{'Clowns' | roleMembers | join(',')}}

For each affected user, I used JMWE's User Property Editor to set these name value pairs.

name: dept

value: CLK

name: dept

value: ACC

etc...

The outcome of this post function creates all subtasks with this Summary:

(Testing): This is the summary value - CLK

This is great for the first user's issue, but I need a way to iterate through this list to append the user property value to the Summary given the value of dept for each user. For instance, another user in the list should have a summary like this.

(Testing): This is the summary value - ACC

I thought about setting the dept value on the newly added subtask but that subtask does not yet exist since I'm creating it on the fly. I could use some help with a script if you'd be so kind. I'm assuming I can bundle the script into the template here to generate the unique Summary during creation.

None of this script here that I've been building has yielded something functional yet but here's what I have in thought.

{% set regex = r/dept/ %}
{% for dept in "User Property" | availableOptions %}
{% if regex.test(dept.value) %}
{% set summary = "(Testing): issue.fields.summary }} - {{issue.fields.assignee | userProperty("dept")}} | find({userProperty("dept") | int}) %)

Thank you for reading,

-Paul

2 answers

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
October 27, 2022

Hi @Paul Alexander 

If I understand correctly, you still want to create a single issue per role member, but you'd like to modify the Summary of the new issues. 

I'm not sure I understand the need to enumerate all entity properties. Can you provide an example?

However, to get the dept property of the "current role member", you could use 

{{it | userProperty("dept") }}
Paul Alexander
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.
October 27, 2022

Ah! The likely magic biscuit. Essentially, embedding the iterator into the specific field to iterate through. I'll try it tomorrow.

I'm never creating more than 8 subtasks during this `create issue` post function. I merely want to append the Summary of each newly created issue with the value of 'dept' given the user found in that project's projectRole with a dept property. Essentially, append the summary with this extra bit of data after the dash shown underlined.

(Testing): This is the summary value - CLK

(Testing): This is the summary value - ACC

etc.

Paul Alexander
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.
October 28, 2022

David, how do I specify the iterator to build the part of the summary shown underlined above? I can see how this works as a standalone, but I can't find syntax to embed this into the template. Thanks again.

Using this:

(Testing): {{ issue.fields.summary }} - {{issue.fields.assignee | it | userProperty("dept")}}

...yields a template-error - (string) Error: filter not found: it

I tried to embed the iterator inside of it but there are too many curly braces.

(Testing): {{ issue.fields.summary }} - {{issue.fields.assignee {{it | userProperty("dept")}}}}
David Fischer
Community Champion
October 28, 2022

Hi @Paul Alexander 

Did you try what I provided earlier? 

(Testing): {{ issue.fields.summary }} - {{it | userProperty("dept")}}
Paul Alexander
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.
October 31, 2022

The problem, David, is that I need to loop through each assignee of the newly created issues in order to get the assignee's dept user property.

This one only works for the first individual.

To set the Summary field:

(Testing): {{ issue.fields.summary }} - {{issue.fields.assignee | userProperty("dept")}}
Using this iterator:
{{'Clowns' | roleMembers | join(',')}} 
Again, this does work to get the first individual, assign the created subtask to him, and set his dept value from the user property when building the Summary value, but it stops there. Every issue created for the remaining members has a summary with the same appended dept value. I need to loop through the user property to set it accordingly...somehow ;).
For instance, let's say there are two members with this 'Clowns' project role...Instead of getting two subtasks created with their dept user property set at the tail of the Summary:

(Testing): This is the summary value - CLK

(Testing): This is the summary value - ACC

I get this, with the same dept value at the tail of the Summary:

(Testing): This is the summary value - CLK

(Testing): This is the summary value - CLK

Notice that the dept value at the end of the summary gets repeated instead of set from the individual's user property. I haven't found a way to embed this additional iterator into the stream if that's possible.

David Fischer
Community Champion
October 31, 2022

Again, did you try the snippet I shared? It should do exactly what you want, since the it variable represents the accountId of the user who becomes the assignee of the new issue. 

Paul Alexander
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.
November 1, 2022

Sorry, David. I somehow goofed this up. Your suggestion works perfect. Sorry about that.

0 votes
Paul Alexander
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.
October 28, 2022

Unrelated, David, is there a means to avoid generating a notification to the assignee of the newly added issue that occurs during this `create issue` post function? I'd like to prevent those users from receiving this notification but there is no configurator on this post function to suppress the notifications. Evern if there were, however, it probably would need to reach out to the newly added subtasks and suppress those notifications. I thought about leaving these newly added subtasks unassigned, but that won't work since I am assigning them now as part of this create issue post function and building the Summary field based on key data.

David Fischer
Community Champion
October 28, 2022

Unfortunately, there is no way to disable the notification emails. That's a limitation of Jira Cloud. 

Suggest an answer

Log in or Sign up to answer