Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,297,503
Community Members
 
Community Events
165
Community Groups

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

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

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.

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

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.

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 siddhesh likes this

Is it possible to do this in Scriptrunner Cloud?

Like Kira Williams likes this

You can add this line to your REST call:

.queryString("notifyUsers", Boolean.FALSE)

Like Rick W likes this

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

Thank you! Immensely helpful

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

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

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

67 views 0 0
Read article

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