Smart actions Enums with different returned value


Is it possible to have a different returned value than the one displayed in Enums for smart actions?
for example:
PARIS = 75

Thank you for your help!

Hello @Simon_BRAMI1,

Please can you explain a bit more on what is your current behavior and what are you trying to achieve? :slight_smile:

I am creating a smart actions with some enum field. Let’s say one city enum with [“Paris”, “Bordeaux”, “Nantes”]
Currently, the string selected is returned to my action route, but I would prefer to have an id returned instead when using:

So every city should have their own id returned instead of their name.

A bit like <option value="75">Paris</option> in a select tag.

Maybe you could add the field zipcode to your smart action fields so you would be able to get zipcode (id in your case) of it, there is an example in our documentation that could help you to achieve it.

Let me know if it helps,

I saw that example, but in my use case, it’s not really what I’m looking for as this smart action will have around 15+ different enums fields with an id attached to each choice… Is it possible to achieve this using a smart collection with static data from json?

Hi @Simon_BRAMI1,

Today the value and the label are the same in enum defined in smart actions.
I’ve just created a feature request in order to support this.


1 Like

Ok thanks!

Then as a workaround to this, I will be creating dictionaries to match the corresponding value based on a string.

const cityType = {
  "Paris": 75,
  "Bordeaux": 33


let cityId = cityType[]

It’s a bit tedious, but it’ll work out!

Thanks :slight_smile:

1 Like