Forums

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

How to get the only first element from Component/s field in ScriptRunner?

Kamal Iqlaas Ismail August 18, 2021

Am trying to get the first name of element when inserted in the Component/s field, as we found out that, when second element inserted, under the inspect element, the list gets sorted alphabetically.

For example, If first element inserted starts with alphabet M , and the second element inserted starts with A, on the GUI we will see exactly like that, but under Inspect (right click mouse), the elements get sorted, which means, the second element is now the first element, which we wrongly captured.

Any pointers will be helpful!

Screenshot 2021-08-18 at 7.07.45 PM.pngScreenshot 2021-08-18 at 7.08.48 PM.png

1 answer

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
August 19, 2021

Hi @Kamal Iqlaas Ismail welcome on the community. I'm sorry but I'm not getting it... you need to read the values with JavaScript or REST API or what? Can you explain your need better?

Kamal Iqlaas Ismail August 19, 2021

Hi @Martin Bayer _MoroSystems_ s_r_o__ , appreciate the response.

Thanks for the direction as well. I need to read the first value only on the interface using the built-in ScriptRunner Script Editor in the JIRA Administration itself.

The Script Editor is using Groovy language.

Let me know if more info needed.

Thank you.

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
August 19, 2021

Hi @Kamal Iqlaas Ismail I'm sorry but I do not think it is possible. After the values are saved, options are sorted.

One solution would be doable (probably). If your use case is

  1. add component B
  2. save
  3. add component A
  4. save
  5. add component C
  6. save

It could be possible to use history records on issues -> what value was the first one in the Component/s field.

Kamal Iqlaas Ismail August 19, 2021

@Martin Bayer _MoroSystems_ s_r_o__ , yes, it is sorted. Appreciate the pointer, will look into how to use the history records. Thank you, have a nice weekend!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events