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
Hi @Sharadkumar Bangera
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
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.ComponentAccessorimport com.atlassian.jira.model.ChangeGroupimport com.atlassian.jira.model.ChangeItemimport com.atlassian.jira.issue.history.ChangeItemBean
def commentManager = ComponentAccessor.getCommentManager()def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = event.issuedef user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()def cf = customFieldManager.getCustomFieldObjectByName("SomeDate")def sd= cf.getValue(issue) as Datedef 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}"
}
It looks like you're new here. Sign in or register to get started.