Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate of in ScriptRunner is not working

Szymon F May 20, 2020

I found out a few days ago that our workflow: Duplicate of is not working properly - to be honest, it is not working at all :)

In the Duplicate Screen I do not see a field to provide the issue key.

Going deeper into the workflow we have a Validator which is getting the error:

Screenshot 2020-05-20 at 17.34.41.png

{
    "canned-script": "com.onresolve.scriptrunner.canned.jira.workflow.validators.CustomScriptValidator (java.lang.String)",
    "class.name": "com.onresolve.jira.groovy.GroovyValidator (java.lang.String)",
    "issue": "SBB-12 (com.atlassian.jira.issue.IssueImpl)",
    "passesCondition": "true (java.lang.Boolean)",
    "transientVars": {
        "issue": "SBB-12 (com.atlassian.jira.issue.IssueImpl)",
        "configuration": "com.opensymphony.workflow.config.DefaultConfiguration@7ec379e0",
        "proj": "Project: SBB (com.atlassian.jira.project.ProjectImpl)",
        "project": "[GenericEntity:Project][name,Test][assigneetype,3][description,][projecttype,software][id,11715][counter,129][avatar,12803][originalkey,SBB][url,][lead,thom][key,SBB] (org.ofbiz.core.entity.GenericValue)",
        "currentSteps": "[SimpleStep@1[owner=, actionId=0, status=To Do]] (java.util.ArrayList)",
        "store": "com.opensymphony.workflow.spi.ofbiz.OfbizWorkflowStore@3fa2ba79",
        "descriptor": "com.atlassian.jira.workflow.ImmutableWorkflowDescriptor@128cb282",
        "userKey": "szymon.fijalkowski (java.lang.String)",
        "originalAssigneeId": "null (org.codehaus.groovy.runtime.NullObject)",
        "commentProperty": "null (org.codehaus.groovy.runtime.NullObject)",
        "entry": "com.opensymphony.workflow.spi.SimpleWorkflowEntry@3db4584",
        "context": "com.opensymphony.workflow.basic.BasicWorkflowContext@38bc3c33",
        "originalissueobject": "SBB-12 (com.atlassian.jira.issue.IssueImpl)",
        "actionId": "51 (java.lang.Integer)",
        "comment": "sad (java.lang.String)",
        "pkey": "SBB (java.lang.String)",
        "roleLevel": "null (org.codehaus.groovy.runtime.NullObject)",
        "commentLevel": "null (org.codehaus.groovy.runtime.NullObject)",
        "transaction": "com.atlassian.jira.transaction.TransactionSupportImpl$TransactionImpl@73b87860"
    },
    "log": "org.apache.log4j.Logger@6f8f6dba",
    "invalidInputException": "null (org.codehaus.groovy.runtime.NullObject)"
}

The Script Editor in ScriptRunner looks like the default one:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField
import com.opensymphony.workflow.InvalidInputException

CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10200l)
String sourceFieldVal = issue.getCustomFieldValue(customField)

IssueManager issueManager = ComponentAccessor.getIssueManager()
Issue issue = issueManager.getIssueObject(sourceFieldVal)

if (issue == null) {
invalidInputException = new InvalidInputException("The 'Duplicate of' ("+sourceFieldVal+") doesn't point to a valid issue.")
}

Errors:

String sourceFieldVal = issue.getCustomFieldValue(customField)

issue is not declared

 

invalidInputException = new InvalidInputException("The 'Duplicate of' ("+sourceFieldVal+") doesn't point to a valid issue.")

invalidInputException is not declared

Does it sound like an error or am I looking in the wrong direction?

0 answers

Suggest an answer

Log in or Sign up to answer