Forums

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

How to get the display value from script runner custom issue picker field?

Rangarajan S September 15, 2021

I am using a Script Runner custom 'Issue Picker' field to display the JQL results the 'Prior Release Names' field. This 'Prior Release Name' works fine and displays the prior values, e.g Release 1, Release 2, Release 3 etc.

However when I pick the value, e.g. Release 3, I need the display value 'Release 3", but this is a custom issue picker, this it returning issue ID e.g. TESTPROJ-15. 

Is there a way that I can populate the release name value from TESTPROJ-xx using some advanced scripting for custom Issue Picker or any other custom scripted fields? I need the custom script dropdown field to be visible in the CREATE Screen.

 

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2021

Yes, you could write a scripted field for this - the pseudo-code for it would be broadly

  • get value of issue picker
  • iterate over issue-picker-value.getFixVersions() using .getName() to build a list of names of the versions
  • Return the list as a string 

You could easily do more than just a list of fixVersions on the issue-picked, but I think your question was about doing the basics.

Rangarajan S September 16, 2021

Thank you very much for the reply. 

Now, I am trying to use the Script Runner "Custom picker." 

In my case the Release Name if not the inbuilt Release feature, My 'Release Name' is a custom field e.g. customfield_12345. 

I need the code to perform the following JQL query

project=TESTPROJ123 AND issuetype ="Action Item"

this should return the value of customfield_12345 (which is my Release Name) in string format.

Please support.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 20, 2021

Sorry for the delay.

I am afraid I am very confused by what you are trying to do now.  You were talking about using the value of an issue picker to get the list of versions of the target issue, but now you've started talking about a query, which has nothing to do with that.

What, exactly, do you want your scripted field to show the users?  Is it the value of customfield_12345 from the issue that you picked with the issue picker?  

Rangarajan S September 21, 2021

Please refer to the screen shot. which displays the 'Prior Release Name', but when I choose a value from the drop down e.g. 'Test Release 1.0' it returns the Issue ID, e.g 'TESTPROJ-1452'. 

Now I need the code which will update a new custom text field [customfield_12345] with 'Test Release 1.0'.

Query1.JPG

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 21, 2021

Ok, that's a start, but you are asking for a field to do something it is not built for.

 

To run over the setup:

 

>which displays the 'Prior Release Name',

Ok, that's fine, that's just the name you've picked for the field

 

>but when I choose a value from the drop down e.g. 'Test Release 1.0' it returns the Issue ID, e.g 'TESTPROJ-1452'. 

 

Yes, this is all the field can do.  It is an "issue picker", intended to let you choose an issue.  It's not there to pick from other bits of data, it is an issue-picker,

 

Later, I see you've mentioned "release name" in fields to search, which isn't really about searching, it's actually about displaying fields from the issue you have picked.

 

 >Now I need the code which will update a new custom text field [customfield_12345] with 'Test Release 1.0'.

 

Ok, so where are you wanting to extract this value from?  I assume it is going to vary, but I'm not sure where you are trying to fetch it from.  The issue-picker field will already pull it from the linked issue, as the "fields to search" setting, but I don't know if that's what you need to get.

Rangarajan S September 21, 2021

Thanks for the response, the understanding is correct. My expectation is, since we have the Issue Key e.g. TESTPROJ-1452, can we extract the Release Name of TESTPROJ-1452 and populate it in customfield_12345. As you rightly mentioned, this issue picker is intended to return the only issue key, which it's doing correctly. May be I am taking a wrong approach.

What are the other alternatives to achieve this? All I need is a picker which returns the list of values from a JQL and when a value is chosen from the picker, the displayed value should be updated to a custom field [customfield_12345]

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 22, 2021

Ok, so your issue-picker gives you an issue to work with when you  ask it for a value.

You can read the value of "release" from that issue, and copy that into your current custom field.

Rangarajan S September 22, 2021

Yes, I need to code for copying the get release value of the dynamically selected issue, so that I can copy  the value into the custom field.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 22, 2021

There are loads of examples for reading custom fields if you visit https://library.adaptavist.com/search?term=custom%20field

Suggest an answer

Log in or Sign up to answer