Hello,
In testing with Groovy 3.0.5/JIRA 6.3.6. We have a number of CannedScripts with custom parameters in them that we are testing for en eventual rollout on a production server, but so far we've been unable to get the parameters, and even more recently, the PostFunction, to ''stick'' (or so to speak)
Initially the script was displaying in the postfunction, but no matter what I entered in the fields the data would be discarded and we'd get back the BuiltinScriptErrors that we'd added to validate the entries, essentially telling me that all of the fields were empty. Injecting logs showed that during the doValidate in the script, none of the parameters has values.
I'm experiencing even stranger behavior now, Once the values are submitted in the postfunction parameters, it doesn't even save the script at all, just bring us back to the ''Select Script'' page and it's not even saving the fact that a script was selected.
I upgraded to 3.0.6 with no change. I tried to copy one of the existing builtin scripts and renamed the class and filename, that script is working just fine, eveything is saving properly. I tried to edit that script by changing the parameter names and types by the ones in my custom script, and I got the same behavior in my custom script.
At this point i've simplified my custom script down as much as possible to determine the source of the problem but still no change, there is nothing that I can see that could be causing this problem.
Any help would be appreciated, i'm entering the said test script in its entirety.
Many thanks,
Eric
package com.onresolve.scriptrunner.canned.jira.workflow.postfunctions import com.atlassian.jira.component.ComponentAccessor import com.onresolve.scriptrunner.canned.CannedScript import com.onresolve.scriptrunner.canned.jira.utils.CannedScriptUtils import com.onresolve.scriptrunner.canned.jira.utils.WorkflowUtils import com.onresolve.scriptrunner.canned.util.BuiltinScriptErrors import com.onresolve.scriptrunner.canned.util.SimpleBuiltinScriptErrors import groovy.util.logging.Log4j @Log4j class TestScript2 implements CannedScript { def projectManager = ComponentAccessor.getProjectManager() def indexManager = ComponentAccessor.getIssueIndexManager() public static final String FIELD_LINK_TYPE = 'Parent_Issue_Link_TypeID' public static final String ISSUE_TYPE = 'IssueType' public static final String PROJECT = 'project' String getName() { return "The Create Task from Approval" } public String getHelpUrl() { return "https://www.google.ca" } String getDescription() { return "Made by ME<br>" "" } List getCategories() { ["Function"] } List getParameters(Map params) { [ [ Name: ISSUE_TYPE, Label: "IssueType", Type: "list", Description: """Select the right issue type to create ;""", Values: CannedScriptUtils.getAllIssueTypes(true) ], [ Name: FIELD_LINK_TYPE, Label: "Parent_Issue_Link_TypeID", Type: "list", Description: """Please enter the Parent Issue link type that is used.""", Values: CannedScriptUtils.getAllLinkTypes(true) ], [ Name: PROJECT, Label: "Project", Type: "list", Description: """Please enter the Project that is used.""", Values: CannedScriptUtils.getProjectOptions(true) ] ] } public BuiltinScriptErrors doValidate(Map params, boolean forPreview) { BuiltinScriptErrors errorCollection = new SimpleBuiltinScriptErrors() if (!params[ISSUE_TYPE]) { errorCollection.addError(ISSUE_TYPE, "You must provide an IssueType.") } if (!params[FIELD_LINK_TYPE]) { errorCollection.addError(FIELD_LINK_TYPE, "You must provide a linktypeID.") } if (!params[PROJECT]) { errorCollection.addError(PROJECT, "You must provide a project.") } errorCollection } Map doScript(Map params) { log.warn('Test string') [:] } String getDescription(Map params, boolean forPreview) { getName() } public Boolean isFinalParamsPage(Map params) { true } }
Yeah this is super-nasty and not easy to spot. I changed the constants to this and it worked:
public static final String FIELD_LINK_TYPE = 'FIELD_PARENT_ISSUE_LINK_TYPEID' public static final String ISSUE_TYPE = 'FIELD_ISSUETYPE' public static final String PROJECT = 'FIELD_PROJECT'
basically the problem is that IssueType is the name of a parameter and the label of a field, and the javascript is pulling the issue type displayed option rather than the value in the select list.
Basically just change it like I have and you should be ok.
You, sir, are a Gentleman, and a Scholar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
;-) I created an issue for this: https://jamieechlin.atlassian.net/browse/GRV-527
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the help! Yes, I imagine it's something very small in them, but I can't for the life of me figure out what. They're in the correct directory, in home/scripts/com/onresolve/scriptrunner/canned/jira/workflow/postfunctions/ (doublechecked just to be sure)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll check this out some time tomorrow... it;s going to be something trivial. It;s just your own canned scripts you are having problems with right? The script/class file is in the correct directory under your scripts dir (ie matching the package)?
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.