Hi All,
sending a notification when custom field value changes.
One notification when a custom field is value changed and then get only this action need to get email notification not more of this email.
example: custom field name laptop and values Acer, Dell, Lenovo
when the change to Acer to dell then the dell team will get an email notification. after the ticket is updated assignee or any other issue updated notification is restricted to the dell team.
Hello @naveen arroju ,
I think you could use the "Send a custom email" feature from ScriptRunner, using this condition (change the field id with yours) :
import com.atlassian.jira.component.ComponentAccessor
def nameOfLaptopField = "Laptop"
def idOfLaptopField = 11001
def laptopField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(idOfLaptopField)
def laptopFieldValue = issue.getCustomFieldValue(laptopField)
def laptopFieldChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == nameOfLaptopField}
if (laptopFieldChanged && laptopFieldValue == "Dell"){
//Send mail to DELL team
return true
}
return false
Make sure you select each event that may be used to change the field value, i.e. Issue updated for a direct edit, or a transition event - in that case position the event after the issue reindex.
Thank you for the update @Antoine Berry
I have modified the code and updated on jira but not work. Can you please check below code
import com.atlassian.jira.component.ComponentAccessor
def nameOfAssigntoqueueField = "Assign To Queue"
def idOfAssigntoqueueField = 10135
def assigntoqueueField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(idOfAssigntoqueueField)
def assigntoqueueFieldValue = issue.getCustomFieldValue(assigntoqueueField)
def assigntoqueueFieldChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == nameOfAssigntoqueueField}
if (assigntoqueueFieldChanged && assigntoqueueFieldValue == "OPS_SLS"){
//Send mail to OPS_SLS team
return true
}
return false
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Antoine Berry,
I have tried the several times above script but not working can you please help on this.
Thank You,
Naveen Arroju.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @naveen arroju ,
please keep in mind that this script is a condition script, meaning that it needs to return "true" for the mail to be sent. You still need to fill the email, subject templates etc.
Also I would need the error message from the logs to be able to help you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Antoine Berry ,
Thank you for the response.
I have tried again unable to get emails.
please find the below details I have mentioned on sending custom email in script runner
1 applied to --> selected projected OPSDEV
2. event ---> issue updated
condition to configuration:-
import com.atlassian.jira.component.ComponentAccessor
def nameOfAssigntoqueueField = "Assign To Queue"
def idOfAssigntoqueueField = 10094
def assigntoqueueField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(idOfAssigntoqueueField)
def assigntoqueueFieldValue = issue.getCustomFieldValue(assigntoqueueField)
def assigntoqueueFieldChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == nameOfAssigntoqueueField}
if (assigntoqueueFieldChanged && assigntoqueueFieldValue == "OPS_SLS"){
//Send mail to OPS_SLS team
return true
}
return false
3. email template
Team,
This is a test email for auto-notifications for the SLS queue.
${issue. summary} has been assigned now to the SLS team and requires your attention.
4. subject templet
Issue ${issue.key} has been assigned to SLS
5. to address
naveen.sri25@gmail.com
6. saved
please find the attached screenshot and payload
{ "projects": "[OPSDEV] (java.util.ArrayList)", "@class": "com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmailCommand (java.lang.String)", "issue": "OPSDEV-1833 (com.atlassian.jira.issue.IssueImpl)", "friendlyEventNames": "Issue Updated (java.lang.String)", "version": "12 (java.lang.Integer)", "relatedProjects": "[[key:OPSDEV, name:(Development Only) NOC Service Desk : xxxxx]] (java.util.ArrayList)", "name": "Send a custom email (java.lang.String)", "canned-script": "com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail (java.lang.String)", "id": "75fb2198-d1ea-4bd0-9885-9a042c839fb3 (java.lang.String)", "event": "com.atlassian.jira.event.issue.IssueEvent@1483ea41[issue=OPSDEV-1833,comment=<null>,worklog=<null>,changelog=[GenericEntity:ChangeGroup][issue,26857][author,ug:7716c452-f8a0-45af-abbf-9ae909429e78][created,2021-11-29 16:44:38.103][id,103841],eventTypeId=2,sendMail=true,params={eventsource=action, baseurl=https://xxxxxxxx-dev.com},subtasksUpdated=true,spanningOperation=Optional.empty]", "bundle": "com.atlassian.jira.event.issue.DefaultIssueEventBundle@3c503a7e", "events": "[2] (java.util.ArrayList)" }
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.
Hi @Antoine Berry ,
Can you please check the above steps and please correct me if I am wrong.
Please reply to me on this issue.
Thank you,
Naveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you,
Ivan.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you’re open to solving this with an app other than scriptrunner, we natively support this kind of config in Notification Assistant for Jira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey everyone,
Is there any way to find whether the a field is updated or not? And can we get its updation date also?
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.