JSON in dynamic fields
So I've been testing out the new JSON in dynamic fields and ran into a few issues. I emailed Ninox and got this response:
Thank you for reaching out and for sharing the details about your use of JSON in dynamic choice fields.
To address your inquiry:
Ninox provides the option to use JSON and HTML for advanced customizations, including dynamic choice fields.
However, please note that this functionality is offered without official support. Implementing and managing it will be at your own responsibility.
If you have any additional questions, feel free to ask!
Huh? Wasn't this a major feature in 3.14?
Here was my original email:
Playing around with JSON in dynamic choice fields.
1) If I build it using something like:
for i from 1 to 13 do
{
id: i,
caption: text(date(2024, i, 1))
}
end
It works fine in choice and multichoice. I can do number(s) and get the selected choices.
text() does not return anything. Is that normal? Is there anyway to get the caption data?
2) If I build the JSON using data from another table or two, and use the recID. Ninox builds the dynamic field but when I try using number(s) I get nothing returned.
What are the current limiations with JSON data in dynamic fields?
Thanks,
What have others encountered with the new dynamic field function?
19 replies
-
Hi, I've just started using the new toy!
It looks like you can get the caption by referring to the field name without the text().
raw('Choice (dynamic)') gives the id as a string.
number('Choice (dynamic)') gives the id as a number.
-
I might be wrong, but as far as I understand the dynamic choice field always converts the id to a string.
The number() function can't translate something like "A1" to a number, but it can do that with an id like "1".
-
said:
It looks like you can get the caption by referring to the field name without the text().Well what do you know.
But if you do a debugValueInfo() on a dC or dMC then you get something like:
dchoice("C7") or dmulti("f1")
not very helpful is you need to use the data. It doesn't really return the caption value in a useful form.
raw() only seems to work for choice fields. multichoice doesn't return an array of choices. So you can modify the Id to:
for rec in getTableA do { id: number(rec.Id), caption: sum(rec.Score) } end
Then you can get something useful.
-
Hi, I'd like to go into this a bit more.
It looks like the dynamic choice field is set up to accept unique strings for IDs, so we can use something like:
[{ id: "Apple", caption: "Apple" }, { id: "Banana", caption: "Banana" }, { id: "Watermelon", caption: "Watermelon" }]
In the above case you can get the values by using raw(), string() or just the name of DC field.
On the other hand, if we put the above JSON into a dynamic multiple choice, we can see the captions, but we can't make any choice. It seems like a bug to me!
-
So far, the JSON functionality in dynamic multiple choice fields need the 'id' property to be a number and we can get the choices by using the numbers() function.
I try to understand how does this really differ from what we already get from the simple multiple choice field.
Can anyone provide us with a use case that we really need this new JSON functionality?
-
I was asking Andy from Nioxus about this in his webinar today and, if I've understood correctly, he said that using JSON means you lose the 'dynamic' feature for the selection field.
-
Hi,
It looks like the text (myChoiceField) isn't working as it should because of a bug.
I posted the issue on the German Ninox forum and got a reply from Uwe (Ninox support):
https://forum.ninox.de/t/60yzncq/json-in-dynamic-choice-field
-
Hi Fred,
Do you know if there's a way we can feed the dynamic choice field with a JSON object programmatically (via Ninox scripting)?
For instance, by clicking a button.
-
Hi, I really appreciate your input.
After hours of trial and error and with the help of your contribution, I have finally found a simple and sustainable solution.
Inside the Text field the JSON string needs to be exactly as below:
[{"id" : 1, "caption" : "Apple"},{"id" : 2, "caption" : "Banana"},{"id" : 3, "caption" : "Watermelon"}]
Once we're inside the Dynamic Choice Field, we'll need to reconstruct the JSON object:
for i in parseJSON(Text) do { id: i.id, caption: i.caption } end
Content aside
- 9 days agoLast active
- 19Replies
- 131Views
-
4
Following