Storing array in a table column
Hello friends,
I am new to Ninox and learning to get acquainted to it.
I have a Parent/Child tables setup (Products and 'Product Details'). In the Products table I have T-shirt types (Round Neck for Men, Boat neck for Men, Boat neck for Women etc.) and in the 'Product Details' table I have stored details about each product in different columns like ('Product Code', 'Unit Price', Size and 'Available Colors'). Data in the 'Available Colors' field is stored using a Multi Choice Combo Box on the form. I don't exactly know how this data is stored internally inside Ninox, whether as text separated by spaces or as an array, but I can see all the available colors per product in the table view as text separated with spaces.
Question: If I were to use the Colors data (from 'Product Details' table) in a script, how would I be able to extract the available colors per product in an array so that I can process that colors data as required inside a script?
The Products and 'Product Details' tables are related in a 1:M relationship (Parent/Child) as the data inside the child table ('Product Details') is only possible if there is a corresponding T-shirt in the parent table (Products).
Now let's come to the 'Invoice Items' table. I want to be able to:
1.Backfill the Product Names from the Products table in a single dynamic choice field on the 'Invoice Items' form.
2. Now based on the selected product from the combo list on the 'Invoice Items' form, it should automatically backfill all the available Colors from the 'Product Details' table (per chosen product) in a single dynamic choice field so that I can select one color per line item on the 'Invoice Items' form while creating an invoice.
There is a M:M relationship between the Invoices table and the Products table through the 'Invoice Items' table.
8 replies
-
Welcome to Ninox.
Since you used the word 'array' in your question, I am guessing you have some DB/coding background.
You are correct, Ninox handles multi choice fields in arrays if you use the numbers(), note the plural form, command. If you create a new formula field in Product Details and put in :
debugValueInfo(numbers('Available Colors'))
You will see the choice number of your selections. Mine says:
number([2,5,6])
The square brackets tell you that Ninox has put the values of the selections into an array and that array is an array of numbers.
Those numbers are the number that Ninox gave each choice as you added them to your multi choice field.
To access items in an array you can use the for loop, or item(), or split(), or contains().
I hope that helps for now. When I get another moment I'll try to answer the 2nd part of your question.
-
Some thoughts:
In your invoice item table you may want to make all fields either text or number fields, or fields that are not linked to other records. You would copy the appropriate data over. This way your invoices will always be a historical record of what was shipped. If you link to other records, if you change the other record then your invoices changes. Also it would allow you to delete items that you no longer carry without affecting your past invoices.
Which means how do you create or modify your invoices? Look into dashboards. You can do a search for "Ninox dashboards" and there will be a few videos to watch.
-
Have you looked at Ninox’s Invoice template for some ideas?
Content aside
- 5 mths agoLast active
- 8Replies
- 52Views
-
2
Following