configuring Automation to trigger an email whenever the value of the Business Process Owner group and my Business Process Owner group type as a Group picker(single group) and i want to implmented thrght Script runner and i am using JIRA cloud
For example: my taget status is Submitted and Business Process Owner group is it group so i want to send an email to it group peoples and my taget status is draft and Business Process Owner group is PSC review group so i want to send an email to PSC review group peoples
Hi @Pavan kumar Mamidipaka
Thanks for the question.
If I understand your requirement correctly, you want to send an email to the members of the group selected in the Business Process Owner field whenever the issue transitions to a specific status.
If that's the case, could you let me know whether you're using Jira Automation only, or are you planning to use ScriptRunner as well? Also, is the Business Process Owner field a native Jira Group Picker or a ScriptRunner custom field?
The answer will determine whether this can be achieved using native automation or if you'll need to retrieve the group members through a scripted solution.
I want to implmented using Script runner but i am using the normal field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear @Pavan kumar Mamidipaka
I have tested the group lookup and notif flow in Jira Cloud and it worked.
User this script.
def groupFieldId = "customfield_10064" // Change your actual field ID
def targetStatus = "Draft" // Change your target status
if (issue.fields.status.name != targetStatus) {
return
}
def groups = issue.fields[groupFieldId] as List
if (!groups) {
logger.warn("No group selected.")
return
}
def users = []
groups.each { group ->
def membersResp = get("/rest/api/3/group/member")
.queryString("groupId", group.groupId)
.asObject(Map)
membersResp.body.values.each { user ->
if (user.active) {
users << [accountId: user.accountId]
}
}
}
users = users.unique { it.accountId }
if (!users) {
logger.warn("No active users found in the selected group.")
return
}
def notifyBody = [
subject : "Issue ${issue.key} requires your attention",
textBody: "Issue ${issue.key} has transitioned to ${targetStatus}.",
htmlBody: "Issue <b>${issue.key}</b> has transitioned to <b>${targetStatus}</b>.",
to: [
users: users
]
]
post("/rest/api/3/issue/${issue.key}/notify")
.header("Content-Type", "application/json")
.body(notifyBody)
.asString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i want to implement Same code for each and every status right??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
While implementing this code through Script runner behaviour i am getting the comile time errors and how do you implement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For this requirement, I would not implement it as a Behaviour. Behaviours are mainly for controlling field behaviour on the issue screen, such as showing/hiding fields, making fields required, or setting field values while the user is editing the issue.
Since you want to send an email when the issue reaches a specific status, the better place to implement this is a ScriptRunner Script Listener or a workflow-related script.
You also don't need to create the same script for every status. You can use one script and check the current status inside it, or configure the listener for the specific transition/status you need.
If you can share the compile error and confirm the exact status where the email should be sent, I will adjust the script for that listener context.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You don't actually need ScriptRunner for this. Native automation can send straight to a Jira group and every member of it gets the email. The one thing it won't do is turn your group-picker field's value into member addresses on its own: the email action's recipient dropdown (Send customized email) only takes static groups or user-picker fields, and a group-picker smart value returns the group's name, not emails.
Since you're dealing with a small fixed set of groups, branch on the field instead. Trigger on the status transition, then add an If/else block: if Business Process Owner is "IT Group", send with the recipient set to the IT Group; else if it's "PSC Review Group", send to that one. No per-status code to duplicate.
https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.