In workflow post function i have added script runner where i written code as below,
Condition
//Declare and initialize the list of issue keys
def issueKeys = ["MYQCMR-42", "MYQCMR-59", "MYQCMR-60", "MYQCMR-78", "MYQCMR-128"]
// Safely access the necessary properties using safe navigation
def issueKey
def issueTypeName d
ef customField23961
// Check if the issue key is in the list, the issue type is 'CMR v2', and custom field 'customfield_23961' is not present
def isConditionMet = issueKeys.contains(issueKey) && issueTypeName == 'CMR v2' && !customField23961 logger.info("Condition met: ${isConditionMet}")
return isConditionMet
Additional Code :
CorrelationId: Self=1-676fe459-5dade21b24c89d6e3b5c5e7d;Root=1-676fe459-44d38642051c894f52c5b974 Script identifier: 8d674583-8b21-4270-bdc2-bdfd3080d833 com.adaptavist.sr.cloud.workflow.RunScript ('Create' transition made for issue MYQCMR-2722) Took: -1ms Logs: 2024-12-28 11:43:24.560 ERROR - org/apache/ivy/util/MessageLogger 2024-12-28 11:43:24.579 ERROR - Class: com.adaptavist.sr.cloud.workflow.RunScript, Config: [className:com.adaptavist.sr.cloud.workflow.RunScript, uuid:8d674583-8b21-4270-bdc2-bdfd3080d833, enabled:true, executionUser:ADD_ON, condition:, description:Clone content based on template selected, additionalCode:import org.apache.http.entity.ContentType; @Grapes([ @Grab(group='com.konghq', module='unirest-java', version='3.11.09') ]) import kong.unirest.Unirest; def issueKeys = ["MYQCMR-42", "MYQCMR-59", "MYQCMR-60", "MYQCMR-78", "MYQCMR-128"] def issueKey = issue.key def issueTypeName = issue.issueType.name def customField_23961 = null def isConditionMet = issueKeys.contains(issueKey) && issueTypeName == 'CMR v2' && !customField_23961 logger.info("Condition met: ${isConditionMet}") return isConditionMet
I can confirm the approach you are trying will not work as expected for Jira cloud.
You can't use annotations like @grab(group='com.konghq', module='unirest-java', version='3.11.09') in the Jira cloud, as this will fail.
If your objective is to clone an issue, you can refer to this code snippet to clone an Epic, Child Issues and Sub-tasks.
Please note that the sample working code in the Snippet is not 100% exact to your environment and requirements. Hence, you must modify the code accordingly.
I hope this help to answer your question. :-)
Thank you and Kind regards,
Ram
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.