Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to disabled notifications on issues modify by Adaptavist ScriptRunner for JIRA Cloud

Paul FLYE SAINTE MARIE February 2, 2018

Hello,

I use Adaptavist ScriptRunner for JIRA Cloud addons and it's awesome.

Problem i have... i need to add some script who modify issue fields but when i execute some script with it : all my user receive an notification : Change By : Adaptavist ScriptRunner for JIRA Cloud.

Is it possible to add on the script : DO NOT SEND notification with the update ?

Thanks a lot.

Regards.

Paul

4 comments

Comment

Log in or Sign up to comment
Neta Elyakim
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.
February 6, 2018

Go to ScriptRunner add on -> Settings -> there you can control the massages the script send, "Notifications Group" you can change it to no group, "Notify Assignee and Reporter" you can disable.

Paul FLYE SAINTE MARIE February 6, 2018

Hi :)

Theses settings is about when the script is failed :
"The group to which email notifications will be sent if a script fails to execute"
And
"Send notifications to the Assignee and Reporter of an issue if a script fails to execute"

My goal is to remove notifications for issues updated by the script.

Thanks for your answer but i think, it's impossible to remove system notifications by script...

Like Kira Williams likes this
Michal Kubiak February 21, 2018

You need to create a notification scheme that doesn't send any notifications. At the start of your script you need to change the project notification scheme to this new one (https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-project-projectIdOrKey-put). At the end of the script you can revert the change to the original one.

Roman Gripp
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 25, 2019

I was able to do it programmatically in ScriptRunner (without using Rest API):

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.notification.NotificationSchemeManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.user.util.UserManager
import org.apache.log4j.Level




log.setLevel(Level.DEBUG)

def projectManager = ComponentAccessor.getProjectManager()
def issueManager = ComponentAccessor.getIssueManager()
def commentManager = ComponentAccessor.getCommentManager()
def userManager = ComponentAccessor.getUserManager()
def notificationSchemeManager = ComponentAccessor.getNotificationSchemeManager()

// delete all comments for given issue in given project
def issue = issueManager.getIssueObject("issue_key")
def project = projectManager.getProjectObjByKey("project_key")
log.debug(project.getName())

def notificationScheme = notificationSchemeManager.getSchemeFor(project)

if (notificationScheme != null){
  log.debug(notificationScheme.getName())
  notificationSchemeManager.removeSchemesFromProject(project)
}

for(comment in commentManager.getComments(issue)){
  log.debug(comment.getBody())
  def user = comment.getAuthorApplicationUser()
log.debug(user.getName())
  commentManager.delete(comment, false, null)
}

if (notificationScheme != null){
  notificationSchemeManager.addSchemeToProject(project, notificationScheme)
}

 

Like # people like this
Tim December 2, 2019

Is it possible to do this in Scriptrunner Cloud?

Like Kira Williams likes this
Rich Scire March 30, 2022

You can add this line to your REST call:

.queryString("notifyUsers", Boolean.FALSE)

Like Rick Westbrock likes this
Kristofer Hansson Aspman _Riada_ March 12, 2020

For ScriptRunner Cloud maybe you're doing something like this in your script:

put("/rest/api/2/issue/${issue.key}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header("Content-Type", "application/json")
.body([
fields:[
(outputCfId): output
]
])
.asString()

Try adding the following line:

.queryString("notifyUsers", Boolean.FALSE)

Which would result in something like:

put("/rest/api/2/issue/${issue.key}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.queryString("notifyUsers", Boolean.FALSE)
.header("Content-Type", "application/json")
.body([
fields:[
(outputCfId): output
]
])
.asString()

This is based on the documentation of the Issue endpoint and there's a few ifs and buts to read in the link (the user that the script is executed by must have some admin privileges).

Like # people like this
Kira Williams
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 22, 2020

Thank you! Immensely helpful

Dennis Alexander September 9, 2020
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.event.type.EventDispatchOption

IssueService issueService = ComponentAccessor.getIssueService()
def user = currentUser

def cf =ComponentAccessor.getCustomFieldManager().getCustomFieldObjects(issue).find {it.name == 'xxxx'}


issueInputParameters.addCustomFieldValue(cf.id, "Hello, world!")
issueInputParameters.setSkipLicenceCheck(true)
issueInputParameters.setSkipScreenCheck(true)
issueInputParameters.setApplyDefaultValuesWhenParameterNotProvided(true)

def update = issueService.validateUpdate(user, issue.id, issueInputParameters)
if (update.isValid()) {
issueService.update(user, update, EventDispatchOption.DO_NOT_DISPATCH, false)
}

issueInputParameters = issueService.newIssueInputParameters()
Dennis Alexander September 9, 2020

the idea is to update an issue by yourself through issueService where you can control sending e-mail (the last param == false)

and then pass an empty issueInputParametrs to the execution pipeline

TAGS
AUG Leaders

Atlassian Community Events