Forums

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

Cannot find matching method java.util.Collection#setConfigParam

馬場泰年 January 16, 2022

I'm new to JIRA/Script Runner 
I want to display  issues in a mutlipicker "ModulesPicker" using setConfigParam method by the workflow  custom script post-function.

But console editor says "Cannot find matching method java.util.Collection#setConfigParam....

My code is as below.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager

def issueManager = ComponentAccessor.getIssueManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def subtaskManager = ComponentAccessor.getSubTaskManager()
def customFieldManager = ComponentAccessor.customFieldManager

def issuePicker = customFieldManager.getCustomFieldObjectsByName("ModulesPicker")
issuePicker.setConfigParam('currentJql','project = XXX')

 

What's wrong? Thanks in advance.

1 answer

0 votes
Nic Brough -Adaptavist-
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.
January 16, 2022

Welcome to the Community!

There's a lot of things wrong here, and there's no direct and simple answer because of that.

  • Post-functions are for doing something (usually updating data somewhere) when someone transitions an issue from one status to another.  They have nothing to do with the display of an issue.
  • getCustomFieldObjectsByName gives you a list of custom fields with that name, not just a single custom field.  The error you are getting is happening because a list does not have a method for "setConfigParam" - it's a list, not a thing with configuration parameters.
  • If you were to look at a field, setConfigParam is about setting its configuration, it has nothing to do with the value of the field. 

I'm guessing you got this code from somewhere like Stack Overflow, which tends to contain a lot of really really terrible and wrong answers because it is too generalised and not curated by people who actually understand the subjects being discussed.

Could you explain what you are actually trying to do here?  Display issues with some calculated data (and why you're not using a scripted field for it), or set some values in a field automatically?  Either way, you would be better off using library.adaptavist.com to base scripts on.

馬場泰年 January 16, 2022

@Nic Brough -Adaptavist- 
Thank you for your answer.

My final intention is to have two ISSUE PICKERs,
then when a user selects an issue in the first PICKER, then the subtasks of the issue will be displayed in the 2nd PICKER.

I want the selecting action for issue in 1st PICKER to be continuously.

I want to be able to continuously perform the action of selecting an issue with 1st Picker

So, I thought that Listener which occurs page transition and Fields which is one-time action could not be handled.
This is reason why I tried to use post-function in Workflow.

(My code I wrote earlier is just the first step.)

Is my idea wrong?
Is there a better another way?

Anyway, I realized that I didn't know about JIRA/Script Runner too much.
Thank you your advices.
I have to study more and more before visiting here again...

Nic Brough -Adaptavist-
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.
January 17, 2022

You can't do this with scriptrunner or any other customisation tool.

You would need to write an entirely new field to handle it.

What you have defined here is a variant cascading-select, where instead of the first half of the field being a select list option, it is an issue picker.  You can do those, there are apps that provide them (but they tend to be clumsy,  and in most cases, it's better  done with an issue link)

the second half of the field would have to be dynamically rebuilt on-screen, from the list of sub-tasks on the issue selected in the first half.  That would mean dynamic javascript to populate it, not a list of options.

That's not an impossible task, but you are going to have to write a full app to provide the field like this.

May I ask what problem you are actually trying to solve with this idea?

Suggest an answer

Log in or Sign up to answer