Pogues icon indicating copy to clipboard operation
Pogues copied to clipboard

VTL expression in Checkbox options

Open ddecrulle opened this issue 2 years ago • 4 comments

Hi 👋,

The VTL expression generated for checkbox options are badly formatted.

Label options are string, so they need to be encapsulated by quotes.

For example, this survey the checkbox is configured as follows Capture d’écran 2022-09-02 à 09 36 04

which generate this :

{
			"componentType": "CheckboxOne",
			"bindingDependencies": ["LOGAUT"],
			"controls": [...],
			"response": { "name": "LOGAUT" },
			"hierarchy": {...},
			"options": [
				{ "label": { "type": "VTL|MD", "value": "OUI" }, "value": "1" },
				{ "label": { "type": "VTL|MD", "value": "NON" }, "value": "2" }
			],
			...
		},

As you can see, options label are not valid VTL expression, this should be generated like this

"options": [ 
   { "label": { "type": "VTL|MD", "value": "\"OUI\"" }, "value": "1" },
   { "label": { "type": "VTL|MD", "value": "\"NON\"" }, "value": "2" }
		],

ddecrulle avatar Sep 02 '22 07:09 ddecrulle

Est-ce que ça serait pas plutôt :

"options": [ 
   { "label": { "type": "MD", "value": "OUI" }, "value": "1" },
   { "label": { "type": "MD", "value": "NON" }, "value": "2" }
		],

Que l'on attend ? Si on considère que le typage a été défini pour éviter d'éventuels traitements VTL inutile. Sur ce point, on a vraiment que du texte.

ORogel avatar Sep 02 '22 08:09 ORogel

Les libellés peuvent être des formules

AnneHuSKa avatar Sep 02 '22 08:09 AnneHuSKa

The VTL|MD type is specifically designed for fields accepting both VTL expressions or Markdown text.

We can nudge users to always use double quotes for field values. Or indeed having an implicit mecanism that would add the missing ones ? Or the Pogues field raising an error when no double quotes are head and tail of the expression / text ?

romaintailhurat avatar Sep 02 '22 11:09 romaintailhurat

For VTL, a string seems to be always with double quotes.

In lunatic the survey is in a json file, so the first double quotes are there to indicated that in the json format it's a string. In lunatic I get the string OUI and then a I send it to VTL. Finanly VTL says to me : it's not a valid syntaxe because OUI does not exist in VTL (We would send to VTL "OUI").

ddecrulle avatar Sep 02 '22 13:09 ddecrulle