Is there a way to dynamically change the type of a column?

Hi, Iโ€™ve got a feature that I want to add to my clientโ€™s app and Iโ€™m wondering if thereโ€™s a smart way to do it.

The app is part of a factory workflow, and every time a factory worker starts or ends a new batch, they need to fill out a number of maintenance fields. Sounds straightforward enough - however, my client would like to be able to edit the fields in the app itself - so they need to be dynamic.

I have another part of the app like this for leftover materials, but thatโ€™s more straightforward because the fields for the material entries are always the same - text name of material, decimal amount of material.
I handle it by having the materials table โ€œbelongโ€ to the batch table, and just generating x rows in leftovers (based on another table called Material Types) related to the batch which can be edited in the batch.

However, the maintenance part is more complicated because the questions could be text, number or yes/no (maybe more things). What I want this to be is a simple table with โ€œMaintenance Itemโ€ and โ€œValueโ€, and the user fills in Value, but the Value is not necessarily always the same type.

One idea I had to get around this was to have three different columns for potential values in the maintenance table and only showing one of them depending on the type, but A) this is going to be an inline table so it will not display properly if I do that, and B) it will probably make something else break later.

Alternatively - is there a way to add/remove/edit COLUMNS themselves from an app? That would be even better, as I wouldnโ€™t have to break up the form with inline tables.

Thanks,
Alex

Solved Solved
0 4 600
  • UX
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Iโ€™ve been tracking may daily activities for several years with an app structured this way.

You could create a virtual column that populates with the textual representation of whichever column contains a value and include this virtual column in the inline table rather than the typed columns.

View solution in original post

4 REPLIES 4

Changing the column type dynamically is not possible. How about if you use Enum field with fixed values like Yes and No. If you set the option โ€œAllow other valuesโ€ as ON, you are able to write text, number, decimal etc. If you need to use number somehow in another place in your app, you can then convert it to a number like NUMBER([EnumColumn]) or DECIMAL()

Steve
Platinum 4
Platinum 4

Iโ€™ve been tracking may daily activities for several years with an app structured this way.

You could create a virtual column that populates with the textual representation of whichever column contains a value and include this virtual column in the inline table rather than the typed columns.

virtual column

oh Steve youโ€™re a legend, this is the solution, thanks

Hi,
I think I have a question about the same case. I have in the data model and app user-defined attributes in addition to the app/entity relevant ones (set up tables for customfields: datatype, list of values . With one table with all rows connecting with user-defined data linked to the relevant other table in the app)).

I am now stuck at the point that I would like these custom fields to be presented in 1 form. Not a (inline) table view to update each custom fieldโ€™s value independently, but the whole set of customfields in one form. Is there a more elegant way than creating an extra table with for all -relevant - datatypes colums 1โ€ฆ20 and making them visible_if (and transporting the data back and forth)?

Top Labels in this Space