not getting notification when assignee is changed

Hi all,

I have tried many workarounds for setting a notification to the assignee. Nothing worked so far.

  • Added a post function to update 'assignee' field , used 'set custom field as function of other fields' to update assignee field and fired 'issue assigned' event in the transition - did not work
  • Added a post function to update 'assignee' field , used 'set custom field as function of other fields' to update assignee field and fired  a custom event  that sends a notification to 'current assignee and reporter' - did not work
  • Removed post function to update assignee field, added a transition screen to set assignee, added both 'issue assigned' and custom event to notify the current assignee

Is there a script I can use in post function that updates, edits and fires a relevant event to notify the assignee.


My workflow is all complete but am struck at the notification part. Please help

1 answer

This widget could not be displayed.
Vasiliy Zverev Community Champion Jun 21, 2016

According to JIRA API when issue is updated it is possible to define is it nessesary to send a notification. 

Here is code for script postfunction (provided by SriptRunner plugin) to set assignee from custom filed:

import com.atlassian.jira.component.ComponentAccessor

issue.setAssignee(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("fieldName").getValue(issue))

It should be executed before standard function "store to database"

Hi Vasiliy,

 

Thanks for the script. I will test it. Can you please help me in going one step further and set assignee based on another custom field's value in the script?

Hi Vasiliy,

I have created a custom field eg: "user" and I used your script in the transition to update assignee to the custom field "user" but assignee did not change on that transition.

import com.atlassian.jira.component.ComponentAccessor
 
issue.setAssignee(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("fieldName").getValue(user))

 

I have included script at the very top, so that is the first action to take place

These are the transition steps

  • Script workflow function : A custom script will be run: from inline script.                                                
  •  Set issue status to the linked status of the destination workflow step.                                            
  •  Add a comment to an issue if one is entered during a transition.                                            
  • Update change history for an issue and store the issue in the database.                                            
  •     Re-index an issue to keep indexes in sync with the database.                                            
  •  Fire a Issue Assigned event that can be processed by the listeners

 

Vasiliy Zverev Community Champion Jun 21, 2016

Here you are:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager

ApplicationUser userName =  ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("РФГ").getValue(issue)

UserManager userManager = ComponentAccessor.getUserManager();
ApplicationUser assignee;

switch(userName.getName()){
    case "vzverev": assignee = userManager.getUserByName("name")
    default: assignee = userManager.getUserByName("default assignee")
}

issue.setAssignee(assignee.getDirectoryUser())

Tried this as well but assignee did not get set.

 

 

Vasiliy Zverev Community Champion Jun 21, 2016

I works on my JIRA instance. Do you run it from postfunction or from Script console?

I used in post function

Post function --> Script post function–> Custom script post function

Did not work.

 

What is the field "name" value : vzverev or Vasiliy zverev (username or fullname )?

Vasiliy Zverev Community Champion Jun 21, 2016

Here should be username of user to assign to. For example vzverev or chubaka.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

102 views 1 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you