We have a requirement to check the and update field value based on the value of another field, Eg.- if A is system field and B is custom field we are looking to capture the corresponding value and check for all the jira issues with the same field value of A where field value for B is empty and need to update the value of B for all the impacted stories with same value field of A, by using listeners during issue created and updated events..Can you please help us to achieve this?
It usually helps to know which line exactly the syntax error is on. And usually, the error will have some details that can help suggest a solution.
But when I copy your snippet, I can see a few errors:
1) you are using the wrong type of quotes around "Fix Version".
2) there is an extra dot after the parens on that same line.
And if you're using the script I supplied in the other thread and just adding the snippet above. Then you're also possibly missing some imports.
But I agree with @Vamsi Kandala if you don't have enough coding experience to be able to resolve simple syntax errors, a scripted listener is probably not for you. An automation rule might be simpler to maintain.
Resolved the syntax errors and the script https://community.atlassian.com/t5/Adaptavist-questions/Need-help-with-setting-up-a-listener-to-verify-a-field-values/qaq-p/2218299?utm_campaign=accept_as_solution_reminder&utm_content=view-answer&utm_medium=email&utm_source=atlcomm#M10495 is running fine without any issues.
Trying to add error handler to the above set the request number field to null if there is any update on the fix versions field and tried to the below code..
if (event.eventTypeId == EventType.ISSUE_UPDATED_ID) {
def listOfFields = ['Fix Version', customFieldName]
def changeItems = ComponentAccessor.changeHistoryManager.getChangeHistoryById(event.changeLog.id as Long).changeItemBeans
log.info "Issue updated detected. Changed fields: ${changeItems*.field}"
if (!changeItems.any { it.field in listOfFields }) {
//don't run the listener if the user changed an unrelated field.
log.warn "$listOfFields were not found in the list of changed fields."
return null
}
if ( changeItems.any { it.field == ‘Fix Version’ }).
{
issue.setCustomFieldValue(customField, null)
customField.updateValue(null, issue, new ModifiedValue(customFieldValue, null), new DefaultIssueChangeHolder())
}
}
Tried both customField.updateValu and issue.setCustomfield methods, but getting the syntax errors.
Please help.....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suggest that using automation rules will be simpler than using the listeners. Please try considering this.
Thanks,
Vamsi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Resolved the syntax errors and the script https://community.atlassian.com/t5/Adaptavist-questions/Need-help-with-setting-up-a-listener-to-verify-a-field-values/qaq-p/2218299?utm_campaign=accept_as_solution_reminder&utm_content=view-answer&utm_medium=email&utm_source=atlcomm#M10495 is running fine without any issues.
Trying to add error handler to the above set the request number field to null if there is any update on the fix versions field and tried to the below code..
if (event.eventTypeId == EventType.ISSUE_UPDATED_ID) {
def listOfFields = ['Fix Version', customFieldName]
def changeItems = ComponentAccessor.changeHistoryManager.getChangeHistoryById(event.changeLog.id as Long).changeItemBeans
log.info "Issue updated detected. Changed fields: ${changeItems*.field}"
if (!changeItems.any { it.field in listOfFields }) {
//don't run the listener if the user changed an unrelated field.
log.warn "$listOfFields were not found in the list of changed fields."
return null
}
if ( changeItems.any { it.field == ‘Fix Version’ }).
{
issue.setCustomFieldValue(customField, null)
customField.updateValue(null, issue, new ModifiedValue(customFieldValue, null), new DefaultIssueChangeHolder())
}
}
Tried both customField.updateValu and issue.setCustomfield methods, but getting the syntax errors.
Please help.....
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.