It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is there a way to automatically remove a specific participant from new issues in Service Desk?

Meg Community Leader Oct 07, 2016

My team runs a service desk separate from that of another department (Non-JIRA), but both are consistently CC'd on each other's requests from Users.

This creates a situation where our automated emails and notifications are creating additional tickets to that department when issues are moving through our system and being resolved.

Is there a way to automatically remove their account as a participant by email address or some other sort of filtering? We would still need to accept tickets from them as the reporter, which is the sticky part.

I do have to add that we are currently only running on Cloud, so our options are a bit limited.

Thanks for your time!

4 answers

import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.issue.DelegatingJiraIssueEvent
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.ComponentManager

def issue = event.getIssue()

// Get the list of participants
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def fieldLayoutManager = ComponentAccessor.getFieldLayoutManager()
def requestField = customFieldManager.getCustomFieldObjects(issue).find {((CustomField)it).name == "Request participants"}
def participants = issue.getCustomFieldValue(requestField)
def filteredParticipants = new ArrayList<ApplicationUser>()
if (participants != null) {
for (ApplicationUser participant in (ArrayList<ApplicationUser>)participants) {
if ( participant.getEmailAddress().toLowerCase() != "ADDRESS_I_WANT_TO_FILTER" )
{
filteredParticipants.add(participant)
}
}
}

MutableIssue editableIssue = (MutableIssue)issue
editableIssue.setCustomFieldValue(requestField, filteredParticipants)
Map<String, ModifiedValue> modifiedFields = editableIssue.getModifiedFields();
FieldLayoutItem fieldLayoutItem = fieldLayoutManager.getFieldLayout(editableIssue).getFieldLayoutItem(requestField);
DefaultIssueChangeHolder issueChangeHolder = new DefaultIssueChangeHolder();
final ModifiedValue modifiedValue = (ModifiedValue) modifiedFields.get(requestField.getId());
requestField.updateValue(fieldLayoutItem, issue, modifiedValue, issueChangeHolder);

Thank you James, this is great!

Where am I supposed to execute this code at?

0 votes
Gerry Tan Atlassian Team Oct 10, 2016

How do customer account get created in your JSD project? Do you allow anyone (even those without account) to create request via email?

0 votes
Meg Community Leader Oct 11, 2016

Hey Gerry,

Yes, we allow anyone to create a request via email. 

Curious if Megan or someone else have firgured this one out? I'd like to remove all request participants in the ScriptRunner postfunction. Any advise would be appreciated.

Suggest an answer

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

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

347 views 1 3
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you