I am trying to get the select list value from JIRA and pass on the value to payload.
Example:
Custom Field = Impact
Type = Select List
If I give the value directly as Impact = "Medium" and pass the payload , I am getting a 200 status code
but if I try with the below method,
def impact = customFieldManager.getCustomFieldObjectByName("Impact")
def impactV = issue.getCustomFieldValue(impact).toString()
log.info("Impact is " + impactV)
am getting the below error,
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.fields.ImmutableCustomField.call() is applicable for argument types: (String) values: [Medium] Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), tap(groovy.lang.Closure), any(groovy.lang.Closure)
Can someone please help me with this?
Hi @Catheline
In your description, you mentioned:-
I am trying to get the select list value from JIRA and pass on the value to payload.
May I know what you are using the pass the value? Is it a Post-Function?
I've done a basic test in my environment using the Post-Function, and I do not seem to be encountering any problems.
From the code that you have shared, I notice a bad approach, i.e.:-
def impact = customFieldManager.getCustomFieldObjectByName("Impact")
This approach has been deprecated.
You should instead invoke your custom field like:-
def impact = customFieldManager.getCustomFieldObjectsByName('Impact').first()
Below is the sample code that I have tested with:-
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def sampleList = customFieldManager.getCustomFieldObjectsByName('Sample List').first()
def sampleListValue = issue.getCustomFieldValue(sampleList) as String
log.warn "=====>>>> Value Selected: ${sampleListValue}"
Below is a screenshot of the test that I have done. I have selected Option 1 from the Sample List field.
Once the issue transitions, the log output returned is:-
2022-08-11 16:42:26,805+0800 http-nio-9091-exec-16 WARN admin 1002x668x1 1incwoo 0:0:0:0:0:0:0:1 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] =====>>>> Value Selected: Option 1
I hope this helps to answer your question. :)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.