Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira SD: Can you add watcher if issue security level is specific?

Teemu Niemi April 30, 2019

Is there possibility to add specific users (or group of users) as an watcher if Jira SD receives ticket where issue security level is set as "Dangerous"?

So kind of scriptrunner listener, where script adds watcher when "Dangerous" issue is created?

1 answer

1 vote
PD Sheehan
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.
April 30, 2019

I generally try to stay away from manipulating watchers. Users won't understand why they are watching issues which they've not interacted with or added themselves as watcher.

You could use a custom listener "send a custom email" instead. You could either just watch issue create event and check for securityLevel == 'Dangerous', or issue updated event and check for a change in security level from anything to 'Dangerous'. 

import com.atlassian.jira.component.ComponentAccessor

def islm = ComponentAccessor.issueSecurityLevelManager
def level = islm.getSecurityLEvelByName('Dangerous')

if(event.eventTypeId ==1) {
//for create event
return event.issue.securityLevelId == level.id
} else {
return event.issue.securityLevelId == level.id && changeItems.any{it.field == 'Security')}
}
Teemu Niemi May 6, 2019

This sounds more logical. It's better to get custom email than mysterious watcher notification. Have to setup this in our test site soon.

Teemu Niemi May 7, 2019

Sorry to inform, but this code throws few errors.

Last line show only ) character, no ( and if I add it before 'Security', more errors is raised.

My coding skills are bad to begin with and I just can't get this to work.

PD Sheehan
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.
May 9, 2019

Remove the ) ... It's not needed. Probably just a typo on my part.

Suggest an answer

Log in or Sign up to answer