Leiste mit Community-Erfolgen erweitern.

Submissions are now open for the 2026 Adobe Experience Maker Awards

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

Enumeration manipulation in javascript

Avatar

Level 2

Hello ,

I've created an enumeration and I'd like to know how I can manipulate the elements of this enumeration in Javascript (for example add/delete/modify elements of this enumeration), but in Javascript

Thanks in advance

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Level 3

Hi, 

Sure!

Given this enumeration as an example:

jorgeferreira_0-1695301958811.png

 

You can insert a line here with the following code:

// insert into enumeration

var sqlFields = "INSERT INTO campaign_dev_DB.neolane.XtkEnumValue (iValueId, iEnumId, sLabel, sName)";
var sqlValues = " VALUES(GetNewId(), 15131, 'Inserted from Javascript', 'insertedFromJS'))"; 

sqlExec(sqlFields + sqlValues);

 

The end result will be:

jorgeferreira_1-1695301998639.png

 

Note: Take into consideration that you need to find a new ID for each line if you want to insert. Depends on the client setup. 
You might need to query xtkNewId to get a new ID (and then increase it!):

select IdSeed XtkNewId where sSequence = 'xtknewid';

 

Other operations such as edit values, remove values, can also be done via SQL in JavaScript.

Lösung in ursprünglichem Beitrag anzeigen

3 Antworten

Avatar

Level 3

Hello, 

 

You can use sqlExec (or other sql functions) to manipulate the table xtkEnum and xtkEnumValue, where all enumerations are stored.

 

Avatar

Level 2

hello @jorgeferreira ,

 

thank you for your reply,
I would like to know if there is a possibility of a small example please.

 

Avatar

Korrekte Antwort von
Level 3

Hi, 

Sure!

Given this enumeration as an example:

jorgeferreira_0-1695301958811.png

 

You can insert a line here with the following code:

// insert into enumeration

var sqlFields = "INSERT INTO campaign_dev_DB.neolane.XtkEnumValue (iValueId, iEnumId, sLabel, sName)";
var sqlValues = " VALUES(GetNewId(), 15131, 'Inserted from Javascript', 'insertedFromJS'))"; 

sqlExec(sqlFields + sqlValues);

 

The end result will be:

jorgeferreira_1-1695301998639.png

 

Note: Take into consideration that you need to find a new ID for each line if you want to insert. Depends on the client setup. 
You might need to query xtkNewId to get a new ID (and then increase it!):

select IdSeed XtkNewId where sSequence = 'xtknewid';

 

Other operations such as edit values, remove values, can also be done via SQL in JavaScript.