Transformation of enumeration id into name or description

Description
D.Ströker
Posts: 2
Joined: Wed Feb 03, 2016 2:03 pm

Transformation of enumeration id into name or description

Postby D.Ströker » Wed Feb 03, 2016 2:26 pm

Hi,
I am using the Polarion API in C# using the Web services.
We defined a custom enumeration the following way:

Code: Select all

<enumeration>
  <option description="1.11" id="v01_11" name="1.11" sortOrder="1"/>
  <option description="1.20 " id="v01_20" name="1.20" sortOrder="5"/>
</enumeration>

In my code I get a WorkItem collection using a query:

Code: Select all

WorkItem[] workItems = TrackerService.queryWorkItems("my query", "id", new string[] { "id", "customFields.productVersion"});

To get the custom enum value, I use a code snippet like this:

Code: Select all

EnumOptionId optionId = workItems[0].customFields.FirstOrDefault(c => c.key == "productVersion").value as EnumOptionId;

As result I will get e.g. optionsId.id == "v01_11"
Now I would like to transform the internal ID "v01_11" into the user friendly text "1.11" like it is defined as name or description for this enum item.

How can I achieve this?

NickEntin
Posts: 472
Joined: Tue Oct 24, 2006 10:27 am
Location: Polarion Software GmbH, Stuttgart
Contact:

Re: Transformation of enumeration id into name or description

Postby NickEntin » Thu Feb 04, 2016 9:33 am

Hi,

looks like you're looking for this method: http://almdemo.polarion.com/polarion/sdk//doc/javadoc/com/polarion/alm/ws/client/tracker/TrackerWebService.html#getEnumOptionWithEnumId(java.lang.String,%20java.lang.String,%20com.polarion.alm.ws.client.types.tracker.EnumOptionId)

TrackerService::

EnumOption getEnumOptionWithEnumId(java.lang.String workitemURI,
java.lang.String enumID,
EnumOptionId id)
throws java.rmi.RemoteException


From EnumOption you can get readable name.

Best regards, Nick

D.Ströker
Posts: 2
Joined: Wed Feb 03, 2016 2:03 pm

Re: Transformation of enumeration id into name or description

Postby D.Ströker » Thu Feb 04, 2016 11:50 am

Hi Nick,
thanks for your answer.
I already used this method but the "name" property of the returned EnumOption object is null.
The call of the method is like this:

WorkItem testItem = this.session.TrackerService.getWorkItemByUri("subterra:data-service:objects:/default/p0042_Platform_AF${WorkItem}p0042-20289");
EnumOptionId optionsId = testItem.customFields.FirstOrDefault(c => c.key == "productVersion").value as EnumOptionId;
EnumOption options = this.session.TrackerService.getEnumOptionWithEnumId("subterra:data-service:objects:/default/p0042_Platform_AF${WorkItem}p0042-20289", "productVersion", optionsId);

Is this the right way? Is the parameter "enumID" set correctly?

Best regards, Dirk

cyberjam
Posts: 1
Joined: Thu Nov 08, 2018 8:02 pm

Re: Transformation of enumeration id into name or description

Postby cyberjam » Thu Nov 08, 2018 8:07 pm

Hello,

I know it's been a while, but has this been resolved?
I am trying to use .getName() as well, and I get Null result.

Is there a solution for this? How can we retrieve the name/description not just the Enumerated ID?

Thank you,

CJ

Jürgen
Posts: 48
Joined: Tue Sep 12, 2017 1:02 pm

Re: Transformation of enumeration id into name or description

Postby Jürgen » Tue Nov 13, 2018 12:44 pm

I basically cannot really help here, but I happened to see something in the configuration.txt file from the upgrade installation, that might be relevant here:
* The ENUM_OPTIONS table is no longer populated by default. If you use the enumerations in the Polarion database for external reporting purposes,
you need to enable this functionality via the the com.polarion.platform.sql.populateEnumOptionsTable=true property in the polarion.properties file.
Refer to Polarion Help > Advanced Administration > Enumerations in the Polarion Database, for more details.


If this has nothing to do with it, please excuse the disturbance.


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 10 guests