Is there a way to use either ScriptRunner or build in Post Functions (or possibly a combination of the two) to have an issue be created based on updates to a custom field?
You can write a listener for issueUpdate event. You can either use Scriptrunner or pure java to write such a listener.
I am providing links here to help you with it :
https://scriptrunner.adaptavist.com/latest/jira/listeners.html#_built_in_listeners
With post function it is not possible as post functions are triggered based workflow status transitions.
Hope this helps.
Regards
Prakhar
Yes it can.
Configure an event listener of type issue updated however this could break your system if not handled properly because if users ever make adjustments on the project or trigger any update, it could fire and create a ticket.
So the question would be why you want this and we can see if there are better alternatives we could suggest.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@stroiai, i have the same concern, what about a trigger specific to a single custom field instead of any update on issue type? I guess this would involve SriptRunner running checks to confirm the change is on the desired custom field.
The use case is that we have JIRA tracking our employees as 'HR Issues'. The request is when HR updates the 'Department' field, it will automatically create a HelpDesk ticket so our sys admins will have a task to update all systems that track a similar value. Email notifications were able to accomplish when we had a single sys admin but as our team grew and more agents came on board, we needed a more systematic process so that there's more accountability rather than an email that can be easily overlooked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Offhand, I do not have a straight answer to this.
However, you could consider adding a condition to check if the field changed using something like is described here: https://community.atlassian.com/t5/Answers-Developer-Questions/Re-Notification-when-field-value-changes-from-quot-A-quot-to/qaq-p/495181/comment-id/32836#M32836
In your case, you would have 2 field values where you trigger your create based on:
Issue issue = event.issue
def oldvalueField = customFieldManager.getCustomFieldObject('customfield_id')
def oldvalue= issue.getCustomFieldValue("customfield_id")
def newvalue = issue.getCustomFieldValue("customfield_id_of_department_field")
if(oldvalue != newValue){
//trigger the create issue method here.
createIssue()
}
static void createIssue(){
//Create issue goes here.
//At the end of create method update the oldvalue to the newvalue
issue.setCustomFieldValue(oldvalueField, newValue))
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
}
This should achieve what you want because when you do the check and the oldvalue is still the same as newvalue then nothing would happen.
Remember though to set your oldvalue to newvalue at the end of the create issue operation.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.