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

Meg Holbrook
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 7, 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!

5 answers

3 votes
James_Mclellan November 9, 2017

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);

Carol Jones October 25, 2019

Thank you James, this is great!

Andrew Pinson November 7, 2019

Where am I supposed to execute this code at?

0 votes
Andreas Lärkfeldt March 5, 2021

I've written a guide on how to fix the original issue (mentioned on top):
https://community.atlassian.com/t5/Jira-Service-Management/Remove-quot-Request-Participants-quot-using-Automation-rule/qaq-p/460812#U1630417

 

No "add-ons" needed :P

 

I hope that helps! :)

0 votes
Dmitry Tyomkin August 22, 2017

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.

0 votes
Meg Holbrook
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 11, 2016

Hey Gerry,

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

0 votes
Gerry Tan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 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?

Suggest an answer

Log in or Sign up to answer