Auto fill value based on which view you are in

My data structure

I have an app with three views sharing the same datasheet.

The first view (All) is based on the full datasheet.

The second view (A) is based on the column slice "Building" of the same datasheet with a value  "A" .

The third view (B) is based on the column slice "Building" of the same datasheet with a value "B".

There are three columns that the users need to fill in, namely "Name", "Quantity", "Building".

The behaviour I want

When the users create an entry under the "All" view, I want the users to fill in all three columns themselves.

But when the users create a new entry under either the "A" or "B" view, I want the "Building" to be auto-filled based on the tab they are currently in.

Is it doable?

Solved Solved
0 8 261
1 ACCEPTED SOLUTION

In the Initial value field, try using:

SWITCH( CONTEXT(โ€œViewโ€),
   โ€œBuilding A View Nameโ€, โ€œAโ€,
   โ€œBuilding B View Nameโ€, โ€œBโ€,
   โ€œโ€
)

 

View solution in original post

8 REPLIES 8

In the Initial value field, try using:

SWITCH( CONTEXT(โ€œViewโ€),
   โ€œBuilding A View Nameโ€, โ€œAโ€,
   โ€œBuilding B View Nameโ€, โ€œBโ€,
   โ€œโ€
)

 

It seems this formula only works for TEXT type. How about ENUM?

I get the following error

 

Column Name 'Building' in Schema 'Inventory_Schema' of Column Type 'Enum' has an invalid 'Initial Value' of '=SWITCH(CONTEXT(โ€œViewโ€),โ€œBuilding A View Nameโ€, โ€œAโ€, โ€œBuilding B View Nameโ€, โ€œBโ€, โ€œโ€)'. The type of the Initial Value does not match the column type. Consider using '' instead.

What is the base type of the enum?

I am not familiar with base type, but the reason for me to use enum is that it can be shown as a drop down list, so that the users can choose either building A or building B.

I don't know if I am doing it correctly, and it does not need to be a enum type, I am fine as long as it can be displayed as a drop down list when creating a new entry.

The base type in one of the setting in the column configuration. It could for example be set as Number, which would cause the error that you're seeing. You probably should have it set as Text.

You don't necessarily need to have a column be an Enum type in order to get a dropdown. You can get a dropdown by putting a List-returning expression into valid_if. There are pros and cons to each way.

https://help.appsheet.com/en/articles/961544-dropdown-from-valid_if

 

Oh, I see. Then the base type is enum for that column. I have changed the base type to text and add valid_if and it works now.

But now it gives me two buttons "A" and "B" to choose from. How to make it a dropdown instead of buttons?

It's right next to where you found the base type.

I understand it now, I was misunderstanding something. I need to click inside the "pen" button under Data>View Columns to see all the details. Thanks!

Top Labels in this Space