Hello,
How do i define a script in behavior 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"
Plz help with the script
1) You can check the action as in https://scriptrunner.adaptavist.com/latest/jira/behaviours-api-quickref.html#_getaction and then execute the operation only for edits
2) Adding automated comment should be handled via listener or postfunction. Behaviour ideally updates the form fields in the screen and is stored in jira only when the user presses the click buttons to go forward. That said, you can set the comment field text to a certain text using behaviours (more like a suggestive text which user can even edit before save)
Refer to https://scriptrunner.adaptavist.com/5.5.8/jira/behaviours-overview.html for more instructions on the apis
Thanks Fazila,
I m using Listener but what should be the scrpirt to add comment in listener when the priority is changed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I am Working in Listener custom Script for my query whenever the Priorities change the Comment to be added in Jira "Priorities changed from Major to Minor".I am not good in scripting.
I m using below script but it require a correction. Please help me where do i define the priority and comment "Priorities changed from Major to Minor".
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.model.ChangeGroup
import com.atlassian.jira.model.ChangeItem
import com.atlassian.jira.issue.history.ChangeItemBean
def commentManager = ComponentAccessor.getCommentManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = event.issue
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = customFieldManager.getCustomFieldObjectByName("SomeDate")
def sd= cf.getValue(issue) as Date
def someDate = sd.format("yyyy-MM-dd")
String comment = "*Automatic comment:* SomeDate was updated to " + someDate
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Single User Picker CF"}
if (change) {
log.debug "Value changed from ${change.oldstring} to ${change.newstring}"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.