Good Afternoon
I am hoping someone is able to provide some insight as to why the following script does not work. I am attempting to use custom script to have comments placed on an issue dependent on a custom field value.
I am using the following script but I am not having any luck:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.comments.CommentManager import com.atlassian.jira.issue.Issue // Get the issue object issue = issue.getIssueType("TWU - Wires") // Get the custom field value def customFieldManager = ComponentAccessor.getCustomFieldManager() def customField = customFieldManager.getCustomFieldObject("TWU - Call Back") def customFieldValue = issue.getCustomFieldValue("TWU - Call Back") // Define the comment manager CommentManager commentManager = ComponentAccessor.getCommentManager() // Add a comment based on the custom field value if (customFieldValue == "Call back completed using two step verification") { commentManager.create(issue, issue.reporter, "Call back completed using two step verification", true) } else if (customFieldValue == "Call back completed - Client is ineligible for two step verification - Client has no SSN on file") { commentManager.create(issue, issue.reporter, "Call back completed - Client is ineligible for two step verification - Client has no SSN on file", true)} else if (customFieldValue == "Call back completed - Client is ineligible for two step verification - Client's contact info does not validate via Innovis") { commentManager.create(issue, issue.reporter, "Call back completed - Client is ineligible for two step verification - Client's contact info does not validate via Innovis", true)} else if (customFieldValue == "Call back completed - Client is ineligible for two step verification - Wire authorized agent is not account signer, no SSN on file") { commentManager.create(issue, issue.reporter, "Call back completed - Client is ineligible for two step verification - Wire authorized agent is not account signer, no SSN on file", true)} else if (customFieldValue == "Call back completed for Consumer International Wire using two step verification") { commentManager.create(issue, issue.reporter, "Call back completed for Consumer International Wire using two step verification", true)} else if (customFieldValue == "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Client has no SSN on file") { commentManager.create(issue, issue.reporter, "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Client has no SSN on file", true)} else if (customFieldValue == "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Client's contact info does not validate via Innovis") { commentManager.create(issue, issue.reporter, "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Client's contact info does not validate via Innovis", true)} else if (customFieldValue == "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Wire authorized agent is not account signer, no SSN on file") { commentManager.create(issue, issue.reporter, "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Wire authorized agent is not account signer, no SSN on file ", true) } else if (customFieldValue == "Call back is not required per Call Back Internal Matrix") { commentManager.create(issue, issue.reporter, "Call back waived per Matrix.", true) }
Hi @Jeremy Outlaw ,
Am not so good with groovy script so I asked one of my friend to help check your script, and this was his output
He revised the codes,
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.Issue
// Get the custom field value
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName("TWU - Call Back")
def customFieldValue = issue.getCustomFieldValue(customField)
// Define the comment manager
CommentManager commentManager = ComponentAccessor.getCommentManager()
// Add a comment based on the custom field value
if (customFieldValue == "Call back completed using two step verification") {
commentManager.create(issue, issue.reporter, "Call back completed using two step verification", true)
} else if (customFieldValue == "Call back completed - Client is ineligible for two step verification - Client has no SSN on file") {
commentManager.create(issue, issue.reporter, "Call back completed - Client is ineligible for two step verification - Client has no SSN on file", true)
} else if (customFieldValue == "Call back completed - Client is ineligible for two step verification - Client's contact info does not validate via Innovis") {
commentManager.create(issue, issue.reporter, "Call back completed - Client is ineligible for two step verification - Client's contact info does not validate via Innovis", true)
} else if (customFieldValue == "Call back completed - Client is ineligible for two step verification - Wire authorized agent is not account signer, no SSN on file") {
commentManager.create(issue, issue.reporter, "Call back completed - Client is ineligible for two step verification - Wire authorized agent is not account signer, no SSN on file", true)
} else if (customFieldValue == "Call back completed for Consumer International Wire using two step verification") {
commentManager.create(issue, issue.reporter, "Call back completed for Consumer International Wire using two step verification", true)
} else if (customFieldValue == "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Client has no SSN on file") {
commentManager.create(issue, issue.reporter, "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Client has no SSN on file", true)
} else if (customFieldValue == "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Client's contact info does not validate via Innovis") {
commentManager.create(issue, issue.reporter, "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Client's contact info does not validate via Innovis", true)
} else if (customFieldValue == "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Wire authorized agent is not account signer, no SSN on file") {
commentManager.create(issue, issue.reporter, "Call back completed for Consumer International Wire - Client is ineligible for two step verification - Wire authorized agent is not account signer, no SSN on file ", true)
} else if (customFieldValue == "Call back is not required per Call Back Internal Matrix") {
commentManager.create(issue, issue.reporter, "Call back waived per Matrix.", true)
}
Goodluck I hope it helped
Dd
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.