Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,558,009
Community Members
 
Community Events
184
Community Groups

Error in scriptrunner code - getting select list values

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?

1 answer

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Aug 11, 2022 • edited

Hi @Catheline Dass

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.

image1.png

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

It helped!! Thank You Ram!!!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events