Forums

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

"No signature of method" on Insight Groovy validation code

Mariano Redondo
Contributor
December 29, 2021

I´m using the Insight "Set the value of an object attribute with a predefined value" post function. I need it to be executed only when issue has an specific request type, so I´m trying to add this groovy validation code:

 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;

def value = issue.get("customfield_10048")?.name
if (value == "Asignación de Notebooks de stock") {
return true;
}
return false;

 

I tested it using the JMWE groovy console and it works perfectly there, but when executed through the workflow transition the update action is not executed, and Ithe following error is logged:

[c.r.j.p.i.s.jira.workflow.InsightWorkflowFunction] Error in groovy script:
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.get() is applicable for argument types: (java.lang.String) values: [customfield_10048]
Possible solutions: getAt(java.lang.String), getId(), grep(), grep(java.lang.Object), wait(), getKey()

 

customfield_10048 corresponds to Request type field.

If I´m not mistaken I have read that request type is not stored as string, so I tried with this modification, which again works fine on JMWE groovy console, but I get the same error when executing though workflow:

 

def value = issue.get("customfield_10048")?.name.toString()

 

Any ideas?

1 answer

1 accepted

4 votes
Answer accepted
David Fischer
Community Champion
December 29, 2021

Hi @Mariano Redondo 

that's because the "get" method is part of JMWE's simplified API, which is only available within JMWE.

You should be able to find the equivalent code, based on the standard Jira API, in ScriptRunner examples here in the Community. It's going to be a few more lines of code.

Alternatively, you can use a Scripted (Groovy) post-function instead, taking advantage of JMWE's simplified API to manipulate Insight Object Attributes: https://innovalog.atlassian.net/l/c/pb53jZCF

For example:

if (issue.get("Insight Object") && issue.get("customfield_10048")?.name == "Asignación de Notebooks de stock")
issue.get("Insight Object").first().setInsightAttributeValue("attribute","value")
Mariano Redondo
Contributor
December 30, 2021

Thanks for the explanation David. I found a solution looking for scripts on the community as you mentioned.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events