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 597
  • 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