Cadet 1st Class
Cadet 1st Class
879 views

Retrieve GlobalList Labels in a Workflow

Jump to solution

Hello,

Does anyone know if there is a way to retrieve the global list labels in the workflow context?

I could only find IDVault.globalList(key) that returns an Array of global list values, but no labels.

Labels (2)
Tags (2)
0 Likes
1 Solution

Accepted Solutions
Commander
Commander

The code I've been using was:

...
cListByName = IDVault.globalQuery(null, "CFilterByName", {"firstName":form.getValue("fcon_name")});
...
if (cListByName[0].length>0){
    ...
}
...

In most cases results received from portal interface APIs are stored in object containing two arrays: [0] for keys and [1] for display values. This applies to global lists too.

Notice I wasn't pushing these values through any field, cause getValues() on the other hand will return only keys. This is what description says:

clipboard_image_0.png

The code for you to get specific description would be

IDVault.globalList(null, "listKey")[1][indexOfWhateverElementFromList]

 and don't forget about locales. 😉

View solution in original post

6 Replies
Commander
Commander

I believe you have to play a bit with the returned object. AFAIR it is a array of arrays and to get to proper list you need to use result[0] to get keys or result[1] to get the labels. Not specifying index gives you the first, as you have noticed.

0 Likes
Cadet 1st Class
Cadet 1st Class
Thank you for your answer.

I tried the field.getValues() function with all the syntaxes I could think of ( 0, "0",[1],"[1]").
It turns out that in any case it always returns me the value (key) of the selected GlobalList field.
Is that the function you're talking about ?
0 Likes
Commander
Commander

The code I've been using was:

...
cListByName = IDVault.globalQuery(null, "CFilterByName", {"firstName":form.getValue("fcon_name")});
...
if (cListByName[0].length>0){
    ...
}
...

In most cases results received from portal interface APIs are stored in object containing two arrays: [0] for keys and [1] for display values. This applies to global lists too.

Notice I wasn't pushing these values through any field, cause getValues() on the other hand will return only keys. This is what description says:

clipboard_image_0.png

The code for you to get specific description would be

IDVault.globalList(null, "listKey")[1][indexOfWhateverElementFromList]

 and don't forget about locales. 😉

View solution in original post

Commodore
Commodore

I know this is an old post, but I thought I'd start here.

I do not believe the answer provided is the correct solution. The solution given is for using IDVault.globalQuery in a form element, not in the workflow. I can tell because the example is using length and is accessing array elements with the [x] notation. In the workflow, IDVault.globalQuery returns a java.util.ArrayList object. You need to use size() with this type of object and you access the elements of the array with this notation : object.get(x)

Did the original poster, or anybody else for that matter, figure out how to access the label values within the workflow?

 

 

0 Likes
Commodore
Commodore
Use the globallist method with size and get to go through the values i guess without testing. But this function should available in the workflow. Just leave out the first arg which normally point to a form field or is null on a form.

Best regards
Michiel Los
0 Likes
Commodore
Commodore

Yes. That is what I am doing, but the object that is returned only has the values, not the labels. The object returned in the form is a multidimensional array that contains the values and the labels. This object does not appear to be multidimensional, or I just don't know how to access the labels.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.