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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,557,119
Community Members
 
Community Events
184
Community Groups

JMWE Post Function Conditional on User Group (cloud)

Hi team! 

I'm my trying (quite unsuccessfully) to execute a Conditional Post Function based on the reporter's "Group" which I have set here: Site Administration > User Management > Groups

  • Reporter's user Group = Analyst
  • Component/s = Acquisition

Can someone please help with how to construct the Nunjunks template? 

chris

3 answers

1 accepted

1 vote
Answer accepted
David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 14, 2018

Try:

{{ issue.fields.reporter | isInGroup("Analyst") }}

But I don't see what the Component/s field has to do with anything here...

Thank you David.  I thought I'd given this syntax a test run to no avail.  must not have.  cheers!

@David Fischer _Appfire_ - I am trying to accomplish the same thing, but I get this error. We are using server, not cloud.  

{{ issue.fields.reporter | isInGroup("Jira Portfolio Management Team") }}

 

Message:
Compilation error(s):
script15608722462601634036350.groovy: 1: Ambiguous expression could be either a parameterless closure expression or an isolated open code block;
   solution: Add an explicit closure parameter list, e.g. {it -> ...}, or force it to be treated as an open block by giving it a label, e.g. L:{...} @ line 1, column 1.
   {{ issue.fields.reporter | isInGroup("Jira Portfolio Management Team") }}
   ^
David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 18, 2019

@SMAtlassianMber JMWE for Jira Server uses Groovy, not Nunjucks.

On Server, you want this:

 issue.get("reporter")?.isInGroup("Jira Portfolio Management Team")
Like David likes this

Hi,

I'm on Server and want to execute a condition based on the name of a group or a role, please help.

Thanks,

John

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 18, 2020

Hi John,

the example right above your question is for Server.

What do you mean exactly by "want to execute a condition based on the name of a group or a role"? Do you need conditional execution of a post-function? Or a workflow Condition?

Hi David,

Thanks for responding!

I want to execute a post function to send an email to Slack upon "Create". The condition is only to allow a group of users. I can create this group or I can create a role and assign these users to it, which way is better?

Ex. So if the Reporter role is "Developers", can the script be as below?

issue.get("reporter") == "Developers"

Thanks,

John

Hi David,

Since the group is small enough, I was able to implement using the below condition:

issue.get("reporter") == "user id 1";"user id 2"...

Thanks,

John

I was able to get this to work instead 

Scripted (Groovy) Validator (JMWE add-on)' Validator

ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Jira Portfolio Management Team")

Thanks. It helped me

Hi @David Fischer _Appfire_

Trust you are doing well, 

we want to add a JMWE postfunction to set a field value based on the Reporter domain.

Ex: we want to set a field value Internal if Reporter domain equals @XXX.com and value External if the reporter domain @YYY.com.

we are able to achieve this with Automation by comparing values like adding condition as {{reporter.emailaddress.split("@").last}} == XXX.com then any action follows.

But we need to add this to postfunction on create to include this value before the triggering create event.

Thanks in advance for your solution,

Best,

Ajay

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 22, 2022

Hi @Atlassian Learner ,

I'm afraid I didn't get that part: 

But we need to add this to postfunction on create to include this value before the triggering create event.

Can you elaborate?

Thanks for reply @David Fischer _Appfire_ 

We would like to a add a postfuctions that populates a field based on the Reporter Domain before the create event is triggeredCancelled to closed.pngFor that, please help us with JMWE conditional execution logic or Built in script.

 Hope it clears now.

Thanks in advance for the help.

Regards,

Ajay

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 23, 2022

Hi @Ajay ,

unfortunately, that won't be possible, as third-party post-functions always run after built-in post-functions (such as "Fire Issue Created event") on Jira Cloud. That's a Jira Cloud limitation.

Thanks  @David Fischer _Appfire_ letting this know.

Is it possible to set a field value based on Reporter Domain ?

If it is can you please help me with the script I should use in the conditional execution section.

Regards,

Ajay

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 26, 2022

Hi @Atlassian Learner ,

why do you need Conditional Execution? Do you have only a single domain you want to check, and thus a single possible value in that custom field?

In that case, you could use something like this:

{% set email = issue.fields.reporter | emailAddress %} 
{{ email.match(r/@(\w+\.\w+)/)[1] == "apple.com" }}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events