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?
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")
Thanks for the explanation David. I found a solution looking for scripts on the community as you mentioned.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.