Removing Add Button from Inline View based on contents of another Cell

Not sure the best approach here. I have two main tables for an app that logs check in and check out dates of Maps.

Maps[Map(key), Name, Town, Status]
and
History[Key, Map, Check In(date), Return(date)]

When a map is checked out the return date is left blank. The “blankness” of that return date drives the Status column in the Maps Table (Google Sheets Side) by an arrayformula that applies “In” “Out” or “Overdue”.

Over to Appsheet, In my UX i have Maps_Detail that has related history in it. It shows all the checkouts and checkins for that map.

What i can’t work out is how to hide the “Add” button in Maps_Detail View if there is a blank return date assiciated with that map already Or if the Status for that map is “Out”.

I’m currently messing around with Behaviour > Actions > [History] > Add (system generated) > Behaviour > Only if this condition is true:

AND(
NOT(IN( CONTEXT(“View”), LIST(“Maps_Detail”))),
COUNT( FILTER(“History”, AND( ([Map] = [_THISROW].[Map]), ISBLANK([Return])))) = 0
)

I don’t think i’m approaching this is the right way, some guidance would be appreciated.

Thank you

Tris

Solved Solved
0 6 1,949
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

The system-generated Add action is not aware of the current row, so you cannot reference _THISROW within its Only if this condition is true expression.

To accomplish what you want, I suggest creating a read-only slice on the History table. In the Maps table, you’ll need two columns that contain the same list of History table references. One will have a Source table of the History table itself, the other will have a Source table of the read-only slice.

3X_8_f_8f9bf3c4d441a1b678f77e3cb416c008bfc152ca.png

Add a Show? expression for each of these two columns so that only the first is shown when Add is allowed, but only the second is shown when Add is not allowed.

See also:

View solution in original post

6 REPLIES 6

Steve
Platinum 4
Platinum 4

The system-generated Add action is not aware of the current row, so you cannot reference _THISROW within its Only if this condition is true expression.

To accomplish what you want, I suggest creating a read-only slice on the History table. In the Maps table, you’ll need two columns that contain the same list of History table references. One will have a Source table of the History table itself, the other will have a Source table of the read-only slice.

3X_8_f_8f9bf3c4d441a1b678f77e3cb416c008bfc152ca.png

Add a Show? expression for each of these two columns so that only the first is shown when Add is allowed, but only the second is shown when Add is not allowed.

See also:

Steve that’s perfect, thank you.

I used the [Status] column of the Map in Show? to display my virtual columns;
REF_ROWS(“History”, “Map”)
and
REF_ROWS(“History Out”, “Map”)
when needed, each with their own specific update options.

Now if a Map has a Status of Out the Add button won’t be there.

Perfect.

I’m sure i can use a similar method to achieve the following but can’t wrap my head around it.

Currently adding a history entry in the history form - direct from the history view (where all entries for all maps are) - allows me to select a Map that is Out in the dropdown. Potentially having a map that has 2 checked out entries.

Thanks in advance

Tris

I’m having trouble following–maybe my coffee hasn’t kicked in yet. Could you elaborate? Perhaps reframe as a new challenge rather than an extension of the previous?

Apologies!

So the goal is to not allow a map to be checked out twice. No two entries for any single map to both have blank return dates.

Your solution stopped a user from doing this from the Related History section in Map Detail view which was perfect.

I also have a primary view for History. Which is all checkout history for all maps. There is always an add button here because the map you want to check out is not yet known in this context, it will be selected in the dropdown on the History Form. In this dropdown all maps are able to be selected even the ones that are already without a return date (hence checked out).

To be honest what i could do is disable that add button completely. And force a user to only check out a map via the Map Detail page where the app knows the map in question and therefore automatically populates the field.

It would be handy to know how this could be done though.

Hope that makes a little more sense

Thank you

Tris

A way to do what you want might be to use Suggested values to offer the user a list of maps that are not currently checked-out.

Thank you Steve i’ll look into it. I’ll disable Add in History context as thinking about it, it just isn’t needed hence solving most of that issue.

really appreciate all the help!

Top Labels in this Space