Get Enumerations in JavaScript

Avatar

Avatar

alexanderh76698

Avatar

alexanderh76698

alexanderh76698

04-08-2017

Hello everyone,

I currently try to get enumerations list in a javascript object.

I wasn't able to find a standarf function in the JS API of campaign, so I fetch all the values using xtkQueryDef.

The return of my query is this:

<enumValue-collection>   <enumValue label="4305615529813"/>   <enumValue label="4305615440668"/> </enumValue-collection>

When I try to parse the XML to get the child nodes (<enumValue>) that actually contain the values I need, I face the issue that it doesn't recognize the hyphen in the parent node. The error message tells me that "collection" isn't defined (it cuts the string at the hyphen).

04.08.2017 13:15:48    js    JST-310000 Fehler bei der Auswertung des Scripts 'rosImportProducts/js' Zeile 40: collection is not defined.

This is what I try:

for(var ean in availProductsRes.enumValue-collection)

  logInfo(availProductsRes.enumValue-collection[ean].@label);

Is there a better way of fetching an enumation list in JS?

Or is this issue (hypen in XML node name) already known at Adobe?

Best regards

Alex

View Entire Topic

Avatar

Avatar

Jean-Serge_Biro

MVP

Avatar

Jean-Serge_Biro

MVP

Jean-Serge_Biro
MVP

17-08-2017

Hi Alexandre,

What does your queryDef look like?

In the 1st post, it seems to be:

for(var ean in availProductsRes.enumValue-collection) 

     logInfo(availProductsRes.enumValue-collection[ean].@label);

so it should become:

either

for(var product in availProductsRes.Products) 

     logInfo(product.@label);

(the toString being automately done by the logInfo method)

but what about the @label missing?

Sorry if I misunderstand something of your queryDef result set.

Regarding the enumerations, sorry I mislead you, I thought you were talking of sys enum in schemas.
If it comes from DB list xtk:enum and not from schema, so you can do either using the queryDef or if it is in a workfklow, you can even use a standard query activity withtarget and filtering mapping schemas xtk:enumValue.
So you can manipulate the context result (usually something as temp:query but you can give other name) as usual.

1280987_pastedImage_2.png

1280988_pastedImage_3.png

Regards
Jean-Serge