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

code for retrieving the value of a custom field is not working

I am trying to retrieve the value of a custom field, the custom field looks like this in my Jira issue: 

Capture1.PNG

I have been able to find the ID by rightclicking on the custom field and choosing the option Inspect Element, Here is the ID: 

Capture.PNGI wrote the following code to extract the value of the custom field: 

 

  def customField =  ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10790");// here replace the ID with ID of your custom field.

  def value = (String)issue.getCustomFieldValue(customField);

                   
log.warn("MOUNA CAMELIA VALUE "+value )

The problem is that I am getting the following value in my log: 

 MOUNA CAMELIA VALUE 1000547

This is a wrong value since it should normally return the value shown below. How to fix this problem?

Capture1.PNG

 

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.
Sep 22, 2023

Hi @Mouna Hammoudi

After reviewing your description, I have a doubt to clarify i.e. what type of custom field are you using for the Invest / Area Theme field?

From the look of the log output you have displayed, I suspect it is a DB Picker you are using. If this is so, then the output returned is correct. The DB Picker will return the id value that has been set in the DB Picker's SQL Configuration. 

If you want to get the value instead of the ID, you can refer to this working example from the Adaptavist Library.

I am looking forward to your feedback and clarification.

Thank you and Kind regards,

Ram

Capture1.PNG

The type of the field is a database values selection field. Should the code here example from the Adaptavist Library work?

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.
Sep 22, 2023

Hi @Mouna Hammoudi

From the screenshot you have shared, this doesn't appear to be the DB Picker field from ScriptRunner. 

Instead, it looks like it's from another third-party plugin.

To proceed, could you please share a screenshot of the field's configuration, i.e. something like:-

db_picker.png

I am requesting this so I can get a better understanding of the field you are using.

If the field is from another third-party plugin, please specify the Vendor the the plugin name.

I am looking forward to your feedback.

Thank you and Kind regards,

Ram

@Ram Kumar Aravindakshan _Adaptavist_ 

Here is a screenshot of the custom field configuration "Invest. Area/Theme"

Capture1.PNG

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.
Sep 25, 2023

Hi @Mouna Hammoudi

I can confirm that the field you are using is not from ScriptRunner. Instead, it is from another third-party plugin called Database Values for Jira.

Jira no longer supports this plugin as it is only compatible with Server instances and not even DC.

I suggest you change the approach you are currently using, i.e. do not use the Database Value for Java's Database Values Searcher field. 

Instead, use ScriptRunner's Database Picker or convert a Single Line Text Field into a Single Select or Multi Select field, depending on your requirement.

Thank you and Kind regards,

Ram

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.
Oct 25, 2023

Hi @Mouna Hammoudi

Have you tried the suggestion I provided and changed the field to Database Picker to convert the Single Line Text Field to a Single or Multi Select List?

If yes, does it solve your issue?

I am looking forward to your feedback.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events