It seems this question keeps poping up. But I ll keep it simple:
1. What is the best way to store checkbox values, when multiple choices are selected?
2. Is it possible to show such record on a read only checkbox?
I also checked Checkbox Component - Appian 21.2, but I could not find the information I am looking for.
I also tried changing the DB and CDT from integer to varchar/text.
Additional topics I looked at:
Appian Community
Kind regards,
Discussion posts and replies are publicly visible
I wouldn't say this has just one answer. You can save it in many different ways depending on your exact use case but what I would say is I've seen many times that people box themselves into needing to save multiple values into the one database field which would then require the use of joinarray() to condense the values into one string and split() to turn it into an array again (Basically what's in here).
I'd say this isn't ideal but obviously depends on your data design on how practical it is to create a many to one table. You'd also have to consider any reporting or views you'd need from this data in the database (if any) as although it's possible it can be problematic to split multiple values from one field.
I'm interested in others views but the "best" way would probably be to have the options driving the checkbox selections in a table in the database and then have a many to many relationship set up to join your record to the reference table.
For question 2, there's always disabled but if you play around with a!richTextDisplayField() you could create a cleaner version.
Thanks for the responses! I guess I am looking for a simple practical example.
In essence, in order to save a textbox value.
a!textField( label: "Purpose", labelPosition: "ABOVE", value: ri!record.purpose, saveInto: ri!record.purpose, characterLimit: 255, required: false )
you need a text CDT
and varchar DB field
What do I need in order to save a value that is a array in a db table?
You need a whole new table!
I wish there would be example of this in a reference app. Thanks for the code you wrote!
The easiest way to do that is to create a separate CDT with just a text field. In your main CDT, use the first CDT as type and make it an array. Appian will then create all necessary tables for you when publishing the data store.