I want to send a custom email after currentUser selects the value in custom Group Picker field and then clicks on Transition Name button on Transition screen.
And is there a way to send individual emails to each user (present in Group) after performing the above action?
How can we configure this in JIRA Data-center by using either scriptrunner, post-functions, JMWE app, or JIRA automation?
As I am new to customizations in JIRA, it would be a great learning for me.
Thank you.
Hi @Digvijay Singh Gehlot ,
Using JMWE Email Issue Post Function, you can achieve your requirement.
Configure the Email Issue Post function as shown below:
Add the below groovy script in the Email addresses field
<% String input = issue.get("customfield_12200").nameString result = input.replaceAll("[\\[\\]]", "") %>${ComponentAccessor.groupManager.getUserNamesInGroup(result).join(",")}
The above script gets the email addresses of all users within the group selected in the field.
Add the conditional execution as shown below to send the email only when the group picker field has some value.
!!issue.get("customfield_12200")
customfield_12200 is the group picker field. Please modify the ID as per your instance.
Hope this helps!
BTW, I am Reshma from Appfire, a vendor of JMWE.
Thanks,
Reshma
Hi @Digvijay Singh Gehlot
this should be possible with scriptrunner and a workflow post-function.
You creste a custom script post function.
Within the script you can grab the issue and the customfieldValue of that userGroup picker, collect all users of that group as a list lf users, iterate over this list and send an email to each user.
BestStefan
Hi @Stefan Salzl
Thank you for your email.
May you share the custom script which I can use in scriptrunner post function as an example?
I will thorough go through that and modify it as per my requirements.
Thanks.
Hi @Reshma Begum {Appfire}
Thank you for your message.
I am successfully able to configure the Email Issue Post Function (JMWE app) at my end as you mentioned.
But I am not able to see email coming to user's inbox.
I am passing the same code in Email Address section (by replacing the cf ID) and it is not giving me any error logs after selecting a value in custom Group Picker (single group) field on Transition screen. Everything looks fine and Green with the Logs. But user is not receiving the email.
However, I tried by selecting "Specific User" and the email is received successfully.
Is there a way we can use "Users from script" or "Users in field(s)" in case of custom Group Picker (single group) field?
Also in HTML Body section, I am adding:
${issue.get("<custom_group_picker_name>").name}
- The output is showing Group Name in brackets i.e. [Test Group] : how can we remove [ ] brackets from the Group Name?
I also want to display user names (present in Test Group) in Email content, so I am adding:
${ComponentAccessor.groupManager.getUserNamesInGroup(issue.get("customfield_XXXXX").name)}
- The output is showing [SSO ID] instead of Full User Name(s) : how can we show full user name - present in Test Group?
Please kindly assist further and let me know if you need any additional details.
unfortunately I don´t have a DC instance on my site. I did a lot of scriptrunner coding at customer site so I know it´s possible with only a script. I can´t use there environment for community use cases but I´ll have a look next week if I can find something similiar in my scripts there.
Furthermore the community is a place to show possibilities and not to get a built custom solution (which some of us do for a living as freelance consultants - no offense).
I would rather suggest to get familiar with scriptrunner and it´s classes and functionalities:
https://docs.adaptavist.com/sr4js/latest/get-started
https://docs.adaptavist.com/sr4js/latest/training
@Digvijay Singh Gehlot
try the following as a starting point:
def issueManager = ComponentAccessor.getComponent(IssueManager)def cfManager = ComponentAccessor.getComponent(CustomFieldManager)def userManager = ComponentAccessor.getComponent(UserManager)def groupManager = ComponentAccessor.getComponent(GroupManager)def groupField = cfManager.getCustomFieldObject("customfield_12306")log.warn(issue.getCustomFieldValue(groupField).name)def benutzerGroups = issue.getCustomFieldValue(groupField)benutzerGroups.each {group -> log.warn "Group name: " + group.name groupManager.getUsersInGroup(group).each { user -> log.warn user.displayName + ", " + user.emailAddress } }
As you figure out the steps of the script you could then use the mail address within the each iterator to send an email to the user.
For the HTML Body section, please modify the script as below:
${ issue.get("customfield_xxx").name.toString().replaceAll("\\[","").replaceAll("\\]", "")}
This will display the group name without brackets.
Please try the below script in the users from script section:
def originalString = issue.get("customfield_xxxx").name.toString()def cleanedString = originalString.replaceAll("\\[","").replaceAll("\\]", "") ComponentAccessor.groupManager.getUserNamesInGroup(cleanedString).join(",")
Please note that we have created a support request SUPPORT-184226 in our portal. We’d like you to sign up for the portal and let us know your username so that we can mark your ID as the reporter so you will be able to access the ticket.Please find the below link to sign up on the portal: linkWe are looking forward to hearing from you!
Thank you so much, it helped me to learn more about Email Issue - Post Function (using JMWE app).
I am able to achieve my use case by following your suggested script changes and can send emails to individual users when a value is selected in custom Group Picker field.
In HTML Body section, I am also able to display User's Full Name instead of their SSO IDs (present in Group) by passing this:
${ComponentAccessor.groupManager.getUsersInGroup(issue.get("customfield_xxxxx)).displayName.join(",")}
Thank you again for creating a Support request on my behalf in your portal. I have signed up for Appfire portal with this username: Digvijay Singh Gehlot and please let me know once my ID is added to that request.
Best regards,
Digvijay
It looks like you're new here. Sign in or register to get started.