Enumeration manipulation in javascript | Community
Skip to main content
New Participant
September 21, 2023
Solved

Enumeration manipulation in javascript

  • September 21, 2023
  • 1 reply
  • 1029 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by jorgeferreira

Hi, 

Sure!

Given this enumeration as an example:

 

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:

 

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.

1 reply

jorgeferreira
New Participant
September 21, 2023

Hello, 

 

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

 

New Participant
September 21, 2023

hello @jorgeferreira ,

 

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

 

jorgeferreira
jorgeferreiraAccepted solution
New Participant
September 21, 2023

Hi, 

Sure!

Given this enumeration as an example:

 

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:

 

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.