I have a groovy script that clones an issue using issueService.clone(user, validationResult) method. I am unable to find a way to read the result or handling the task completion notification from the current documentation. My use case is to wait until the clone operation is complete and get the clone issue key/object.
Any help is appreciated.
Hello @Bhaskara Yandava
The thing is, that issueService.clone() itself returns AsynchronousTaskResult that have method isValid() which returns results of clone.
ref
And here is some example for you
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
def issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-1")
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("some_custom_field_object")
Map<CustomField, Optional<Boolean>> map = [:]
map.put(cf, Optional.of(true))
def issueService = ComponentAccessor.getIssueService()
def issueCloneValidationResult = issueService.validateClone(user, issue, "Some summary", true, true, true,map)
if (issueCloneValidationResult.isValid()){
def cloneResult = issueService.clone(user, issueCloneValidationResult)
if(cloneResult.isValid()){
log.error("Clone successful")
}
else{
log.error("There are some errors during cloning"+ cloneResult.getErrorCollection().getErrorMessages())
}
}
Hope it helps!
Thank you for your quick reply Mark. isValid() is only providing me the status of the operation. From the esult object I am able to get only the task id but not any issue key or id. Is there a way to collected that information?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I ve made little research and it seems you can't.
But you can use IssueFactory to clone issues instead of IssueService.
Please check my answer bellow
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.