How do i define a script in Listener - field,
1)which should be executed only during the EDIT screen,
2)if priority is changed from major to minor, it should add comment in ticket " Priority changed from major to minor"
Please provide the script if there is any , i already refer various google answer but it failed when i implemnted it
Script which i used and it is incomplete, kindly help me with above requirement
I used Listener- Field
import com.atlassian.jira.component.ComponentAccessor
issue.priority?.name == 'Blocker'
issue.summary == 'Priority is changed'
1)which should be executed only during the EDIT screen,
Script Listener is designed to work based on the Events - that means the Listener would not know if the action was done on the screen or inline edit or REST API calls.
2)if priority is changed from major to minor, it should add comment in ticket " Priority changed from major to minor"
def field = event.getChangeLog().getRelated('ChildChangeItem').find{it.field == "Priority"}; def old_field_value = field.oldstring; def new_field_value = field.newstring;
if (old_field_value == "Major" && new_field_value == "Minor") {
do something here
}
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.getCommentManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
if (old_field_value == "Major" && new_field_value == "Minor") {
commentManager.create(
issue,
user,
"Priority changed from Major to Minor",
false)
}
Disclaimer: I have not tested the code above. These are all from a very old script that I have before.
Thanks,
Moga
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.