Parsing Custom field of type "Version Picker"

I'm pulling JIRA data into my database using a Perl script to create csv files, which are then imported to the database. While I'm able to pull in the "affectsVersions" and "fixVersions", I'm having trouble pulling in just the displayed string for a custom field of the same type, "Version Picker". (It's custom field number "10780" below).

Here's the related snippets...

sub getSingularObjectFromString($$);

print(getVersions($issue->{affectsVersions}) . $DELIM); # gets displayed contents
print(getVersions($issue->{fixVersions}) . $DELIM); # gets displayed contents
print(getSingularObjectFromString($issue, 10780) . $DELIM); # Trying to get just the "displayed" contents

 

...for "affects versions" and "fixVersions" I can just pull the data by using "getVersions"...

sub getVersions {

my ($versions) = @_;

my $str;

return "" if (scalar(@$versions) == 0);

foreach my $version (@$versions) {
if ($str) {
$str .= ", " . $version->{name};
} else {
$str = $version->{name};
}
}

return $str;
}

...but since "testVersions" is a custom field  (of the same type as the others), I'm trying to get just the displayed/rendered value that appears.

 

# Trying to get just the "displayed" contents of the "test version" custom field. Tried several variations here...

 

sub getSingularObjectFromString($$) {

my ($issue, $fieldID) = @_;

my $customFields = $issue->{customFieldValues};

return "" if (scalar(@$customFields) == 0);

foreach my $customField (@$customFields) {

if ($customField->{customfieldId} eq "customfield_$fieldID") {
return $customField->{values};
}
}

return "";
}

 

...My scripts work fine and pull a version number (such as "4.3.2.1") for both "affectsVersions" and "fixVersions", but for the custom field it seems to be pulling a number that JIRA uses as a reference to those versions, so I get something like "23591" instead of "4.3.2.1". Am I missing something? I've tried these methods and a few more...

getValueFromIssue

getExternalFieldValue

getSingularObjectFromString

getCustomFieldValue

All of these pull the "number" from the custom field, not the displayed value.

Is there a way to get the displayed Test Versions of "4.3.2.1" that is displayed when the issue is viewed in JIRA? Any insight would be helpful. Thanks!

 

1 answer

Let me summarize with an example. I have a fixVersion that displays "4.3.21.4" on the JIRA issue screen. I also have a Tested Version that also displays "4.3.21.4" on that same issue. Both of these reference (internally, in JIRA) a "number". For this example that number is "23303". When I try to pull the values from these JIRA fields, I get "4.3.21.4" for the fixVersion, but "23303" for the Tested Version. How do I get the value that is being displayed by JIRA for my custom field, instead of the number 23303?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,316 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot