I want to trigger emails and assign the issue to same as user picker value. How can I achieve that?
For an example: If I select abc@gmail.com for cf TVT in create screen it should assign an issue to the user and send mail notification.
@Imdad KP
You can create a Post Function which will copy the field TVT to assignee field in JIRA. You can assign this Post Function on Create Issue Transition.
JIRA Notification Scheme will take care of sending the mail to assignee unless it is customised otherwise
For creating the Post Function there are many add-ons you can use (based on if you have them in your system )
Some examples are :
Scriptrunner
Update on Transition
JSU
JIRA Misc Workflows
You may explore them
Regards
Prakhar
Hi @Prakhar Srivastav {Appfire} ,
Thanks for that, is it possible to provide you with any sample groovy script for the same. I am using Scriptrunner plugin for this process.
Thanks,
Imdad KP
Hi @Imdad KP
You can find many articles for this. For example you can refer this link :
https://community.atlassian.com/t5/Jira-questions/Updating-assignee-via-scriptrunner/qaq-p/637155
Hi Prakhar,
I am writing this the first time. Could you please help me to understand the issue here.
package com.imdad.scripts
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.customfields.option.Optionimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.user.ApplicationUserimport com.atlassian.jira.user.UserUtilsimport org.apache.log4j.Levelimport org.apache.log4j.Logger
def log = Logger.getLogger("com.imdad.scripts")log.setLevel(Level.INFO)
def approversFiledMapping = ["BVT" : "customfield_11120", // Assignee user picker field id"IVT" : "customfield_11127","FVT" : "customfield_11128","SVT" : "customfield_11129","PVT" : "customfield_11130","AVT" : "customfield_11131","GVT" : "customfield_11132","TVT" : "customfield_11133"]
//current issue objectIssue issueContext = issuelog.debug("current issue key - ${issue.key}")def issueFactory = ComponentAccessor.getIssueFactory();def issueManager = ComponentAccessor.getIssueManager();def authenticationContext = ComponentAccessor.getJiraAuthenticationContext();def customfieldManager = ComponentAccessor.getCustomFieldManager()
CustomField cfTestingType = customfieldManager.getCustomFieldObject("customfield_11120") //Testing Type field IDCollection<Option> cfTestingTypeValues = (Collection<Option>)issue.getCustomFieldValue(cfTestingType)log.info("testing types ${cfTestingTypeValues}")if(cfTestingTypeValues && !cfTestingTypeValues.empty){for(Option option: cfTestingTypeValues){log.info("Testing Type value ${option.value}")// create new issue from factorydef issueObject = issueFactory.getIssue();//set valuesissueObject.setProjectObject(issue.getProjectObject()); //setting target projectissueObject.setIssueTypeId("10502"); //setting target issue typeissueObject.setSummary(issue.getSummary()); //Copying summaryissueObject.setDescription(issue.getDescription()); //copying descriptionissueObject.setReporter(issue.getReporter()); //copying reporter
CustomField cf = customfieldManager.getCustomFieldObject(approversFiledMapping.get(option.getValue()))if(cf){ApplicationUser user = (ApplicationUser)issue.getCustomFieldValue (cf)if(user){log.info("Approver ${user.name}")issueObject.setAssignee (user) //set Assignee}}
//copy customfield valuesCustomField cfROO = customfieldManager.getCustomFieldObject("customfield_11100") //Release Overviewif(cfROO){issueObject.setCustomFieldValue(cfROO, issue.getCustomFieldValue(cfROO))}else {log.debug("Release Overview customfield not found....")}
CustomField cfSAL = customfieldManager.getCustomFieldObject("customfield_11101") //Scopeif(cfSAL){issueObject.setCustomFieldValue(cfSAL, issue.getCustomFieldValue(cfSAL))}else {log.debug("Scope customfield not found....")}
CustomField cfOI = customfieldManager.getCustomFieldObject("customfield_11102") //Offering Informationif(cfOI){issueObject.setCustomFieldValue(cfOI, issue.getCustomFieldValue(cfOI))}else {log.debug("Offering Information customfield not found....")}
//create actual issuedef targetIssue = issueManager.createIssueObject(authenticationContext.getLoggedInUser(), issueObject)log.info("Target Issue Key - ${targetIssue.key}")}}
What I am trying to achieve here, whenever I choose any user value in BVT or IVT etc.. JIRA should create that many number of issues and the same user will get assigned the ticket.
It looks like you're new here. Sign in or register to get started.