Expand my Community achievements bar.

Adobe Campaign User Groups are live now. Join our Adobe Campaign User Groups and connect with your local leaders!
SOLVED

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 Accepted Solution

Avatar

Correct answer by
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.

View solution in original post

3 Replies

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

Correct answer by
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.