How to set project specific select field value from Blitz Action button script

NeilW December 10, 2015

I've implemented a Blitz Action button to allow me to create and link an issue to the current issue.

I'm able to copy over values from several existing issue custom fields to the new issue custom fields.  The problem is that I cannot copy over such values for my Project Specific Select field.  

I've tried two approaches, both of which work for the standard JIRA select field (Platform) but do not work for the Project Specific select field (Goal).

Approach #1 used custom field mappings: 

// Get values passed from screen script
string newSummary = getElement(argv, 1);
string newDescription = getElement(argv, 3);
string newDesigner = getElement(argv, 5);


// Create new "UI Design" issue
date newDueDate;
interval estimate;
string[] newComponents;
string issueType = "UI Design";
string[] customFieldMappings = { "Designer", newDesigner, "Product Manager", #{Product Manager}, "Platform", #{Platform}, "Goal", #{Goal} };
string newIssueKey = createIssue(
    project, 
    "", // parent issue key 
    issueType,
    newSummary,
    priority, 
    newDescription,
    newComponents,
    newDueDate, 
    estimate, 
    securityLevel, 
    customFieldMappings);

 

Approach #2 uses code to set the field value explicitly if in context:

// Get values passed from screen script
string newSummary = getElement(argv, 1);
string newDescription = getElement(argv, 3);
string newDesigner = getElement(argv, 5);


// Create new "UI Design" issue
date newDueDate;
interval estimate;
string[] newComponents;
string issueType = "UI Design";
string[] customFieldMappings = { "Designer", newDesigner, "Product Manager", #{Product Manager} };
string newIssueKey = createIssue(
    project, 
    "", // parent issue key 
    issueType,
    newSummary,
    priority, 
    newDescription,
    newComponents,
    newDueDate, 
    estimate, 
    securityLevel, 
    customFieldMappings);

// Set new issue's Goal field (Does not work for Project Specific select field)
if (isCustomFieldInContext("Goal", project, issueType) && #{Goal} != "")
{
     %newIssueKey%.#{Goal} = #{Goal};
}


// Set new issue's Platform field (This works for standard JIRA select field)
if (isCustomFieldInContext("Platform", project, issueType) && #{Platform} != "")
{
     %newIssueKey%.#{Platform} = #{Platform};
}

Any hints would be much appreciated.

Thanks,

Neil Wheaton

 

3 answers

0 votes
Deepali Bagul November 1, 2017

Hello @NeilW,

Were you able to resolve this issue at your end. I am running into the same issue. Thanks in advance.

Regards,

Deepali

0 votes
NeilW April 4, 2016

Just updated to JIRA 7.1.2 and Project Specific Select Field 2.5.3.  I still cannot copy over the field value.

Code:

// Set new issue's Goal custom field to match that of the current issue
if (isCustomFieldInContext("customfield_10700", project, issueType) && customfield_10700 != "")
{
    %newIssueKey%.customfield_10700 = customfield_10700;
}

Catalina.out error:

2016-04-04 16:23:40,635 pool-30-thread-2 ERROR nwheaton 1145x33259x2 11uhm1a 10.144.12.21,127.0.0.1 /rest/keplerrominfo/blitzactions/latest/input/executeAction [c.k.j.p.blitzactions.core.AsyncBlitzRunner] Running blitz script failed.

com.keplerrominfo.sil.lang.SILException: Exception while executing SIL program >>BlitzAction Create UI Design on PLAY-32<<

        at com.keplerrominfo.jira.commons.silrunner.UnifiedSilRunner.throwAway(UnifiedSilRunner.java:234)

        at com.keplerrominfo.jira.commons.silrunner.UnifiedSilRunner.interpret(UnifiedSilRunner.java:129)

        at com.keplerrominfo.jira.plugins.blitzactions.core.AsyncBlitzRunner$1.createResult(AsyncBlitzRunner.java:141)

        at com.keplerrominfo.jira.plugins.blitzactions.core.AsyncBlitzRunner$1.createResult(AsyncBlitzRunner.java:128)

        at com.keplerrominfo.jira.commons.threading.JiraCallable.call(JiraCallable.java:62)

        at java.util.concurrent.FutureTask.run(FutureTask.java:266)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

        at java.lang.Thread.run(Thread.java:745)

Caused by: com.keplerrominfo.jira.commons.jira.utils.JiraOperationException: Update failed for issue >>PLAY-112<<, error was java.lang.ClassCastException: java.lang.String cannot be cast to com.atlassian.jira.issue.customfields.option.Option

        at com.keplerrominfo.jira.commons.jira.utils.IssueUtils.updateIssue(IssueUtils.java:448)

        at com.keplerrominfo.jira.commons.ivm.SILIssue.saveFieldsToIssue(SILIssue.java:123)

        at com.keplerrominfo.jira.commons.ivm.DefaultIssueVariableResolver.applyResults(DefaultIssueVariableResolver.java:51)

        at com.keplerrominfo.jira.commons.ivm.IssueSILInterpreter.interpret(IssueSILInterpreter.java:155)

        at com.keplerrominfo.jira.commons.silrunner.UnifiedSilRunner.interpret(UnifiedSilRunner.java:120)

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to com.atlassian.jira.issue.customfields.option.Option

        at com.atlassian.jira.issue.customfields.impl.SelectCFType.getDbValueFromObject(SelectCFType.java:68)

        at com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType.createValue(AbstractSingleFieldType.java:138)

        at com.atlassian.jira.issue.fields.CustomFieldImpl.createValue(CustomFieldImpl.java:731)

        at com.atlassian.jira.issue.fields.CustomFieldImpl.updateValue(CustomFieldImpl.java:446)

        at com.atlassian.jira.issue.fields.CustomFieldImpl.updateValue(CustomFieldImpl.java:432)

        at com.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue(DefaultIssueManager.java:669)

        at com.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue(DefaultIssueManager.java:655)

        at com.keplerrominfo.jira.commons.jira.utils.IssueUtils.updateIssue(IssueUtils.java:437)

        ... 11 more
Holger Schimanski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2016

What custom field type is customfield_10700? Project Specific Select Field (simple)?

0 votes
Holger Schimanski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2015

If your approach is working for standard JIRA text field or standard JIRA select field, then this should also work for Project Specific Select fields.

Custom field type Project Specific Select Field (simple) is based on a standard JIRA text field. Project Specific Select Field and Project Specific Multi Select Field are based on select field.

Maybe this helps?
Holger

Suggest an answer

Log in or Sign up to answer