@Thanos Batagiannis [Adaptavist]
I did run script below, but looks like no clone issue was created.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.link.IssueLinkTypeManager import com.onresolve.scriptrunner.canned.jira.utils.ConditionUtils import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue def issue = issue as MutableIssue def customFieldManager = ComponentAccessor.getComponent(CustomFieldManager) def customField = customFieldManager.getCustomFieldObjectByName("SelectListA") def cfValue = customField.getValue(issue) def targetProjectKeyA = "JRA" def blocksId = ComponentAccessor.getComponent(IssueLinkTypeManager).getIssueLinkTypes().findByName("Blocks")?.id def inputs = [ issue : issue, (CloneIssue.FIELD_LINK_TYPE) : blocksId, (ConditionUtils.FIELD_ADDITIONAL_SCRIPT): """issue.setSummary('my summary')""", (CloneIssue.FIELD_SELECTED_FIELDS) : null, //clone all the fields
(CloneIssue.SKIP_EPIC_LINKS) : "true",
(CloneIssue.FIELD_USER_KEY) : "admin",
] as Map<String, Object> log.debug "Value of custom field is ${cfValue}" if (cfValue?.toString() == "AAA") { inputs.put((CloneIssue.FIELD_TARGET_PROJECT), targetProjectKeyA) new CloneIssue().doScript(inputs) }
Hey Q,
Did you change the names to match your's ?
Also this should be a post function in the create issue transition, after the Issue Created step.
One last thing, did you check your logs for any errors ?
regards, Thanos
@Thanos Batagiannis [Adaptavist]
Yes it works. Thanks, Will this contain clone and link operation?And , I would like to change from block to 'is caused by' what is the keyword I should use?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad to hear that Q, could you please accept the answer so others may benefit from it ?
Regards, Thanos
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.
Hey Q,
You can navigate to the Issue Types section in your jira, or you can use the following script in your script console and get the list
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
ComponentAccessor.getComponent(IssueLinkTypeManager).getIssueLinkTypes().collect {
"Name: ${it.name} | Inward name: ${it.inward} | Outward Name: ${it.outward}"
}.join("<br>")
Regards, Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Thanos Batagiannis [Adaptavist]
Is there anyway I can add 'As user' The user that will run as, like the function we have in the clone,link buildin function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I edited your script, adding the "as User" field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Thanos Batagiannis [Adaptavist]
I hit errors as below:
2017-11-03 13:09:16,575 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2017-11-03 13:09:16,575 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: EC-26, actionId: 1, file: <inline script> com.atlassian.jira.exception.CreateException: Cannot retrieve configured user abc for cloning issue. Reconfigure function. at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue.doScript(AbstractCloneIssue.groovy:131) at com.onresolve.scriptrunner.canned.jira.utils.CopyIssueWithAttachments.super$2$doScript(CopyIssueWithAttachments.groovy) at com.onresolve.scriptrunner.canned.jira.utils.CopyIssueWithAttachments.doScript(CopyIssueWithAttachments.groovy:13) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue.super$3$doScript(CloneIssue.groovy) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue.doScript(CloneIssue.groovy:102) at com.onresolve.scriptrunner.canned.CannedScript$doScript.call(Unknown Source) at Script401.run(Script401.groovy:31)
user abc is a admin user
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is "abc" his user key ?
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.
try the script below in your script console
import com.atlassian.jira.component.ComponentAccessor
ComponentAccessor.getUserManager().getUserByName("abc")?.key
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Thanos Batagiannis [Adaptavist]
2017-11-03 13:12:29,663 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2017-11-03 13:12:29,663 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: EC-28, actionId: 1, file: <inline script> com.atlassian.jira.exception.CreateException: Cannot retrieve configured user ABC for cloning issue. Reconfigure function. at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue.doScript(AbstractCloneIssue.groovy:131) at com.onresolve.scriptrunner.canned.jira.utils.CopyIssueWithAttachments.super$2$doScript(CopyIssueWithAttachments.groovy) at com.onresolve.scriptrunner.canned.jira.utils.CopyIssueWithAttachments.doScript(CopyIssueWithAttachments.groovy:13) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue.super$3$doScript(CloneIssue.groovy) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue.doScript(CloneIssue.groovy:102) at com.onresolve.scriptrunner.canned.CannedScript$doScript.call(Unknown Source) at Script404.run(Script404.groovy:31)
Replaced with user key, got error above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Probably the
def blocksId = ComponentAccessor.getComponent(IssueLinkTypeManager).getIssueLinkTypes().findByName("Blocks")?.id
does not exist (returns null) therefore does not create any link.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Thanos Batagiannis [Adaptavist]
Looks like sometimes it show as current user created the clone issue, sometimes 'As user' create clone issue. Any suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Qi Jiang
I was looking at your post and I was wondering how you figured the properties for
(CloneIssue.FIELD_LINK_TYPE) (ConditionUtils.FIELD_ADDITIONAL_SCRIPT) (CloneIssue.FIELD_SELECTED_FIELDS)
(CloneIssue.SKIP_EPIC_LINKS)
(CloneIssue.FIELD_USER_KEY)
I'm trying to find the property for PARENT and I can't find documentation anywhere.
I would appreciate it if you could help me find it.
Thanks!
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.