How to conditionally enable Add/New button fo...

(Hopp Karla) #1

How to conditionally enable Add/New button for inline reference table?

I have two tables, “report” and “detail”, which is a ref table to “report”. A report can have many details: detail[report_id] = report[id] .

I would like the user to be able to add further report details via the inline view, provided the report has not been flagged as “reviewed” (report[reviewed] is a boolean). I’ve tried adding a condition to the Add action for the detail table, but I can’t seem to snag the value of the reviewed column for the report record to which the detail records are related.

Even though the Expression Assistant recognizes the names of columns in the detail table, it does not really seem to have access to them. I’ve tried something like this, which works if you click the Test button in the Expression Assistant, but it doesn’t actually work for the Add action. NOT(ANY(SELECT(report[reviewed], [id] = [report_id])))


ANY(SELECT(report[reviewed], [id] = [report_id])) = false

Note that this sort of condition works for the Edit and Delete buttons once you have selected a detail record from the inline view.

Any advice?

(Gil Littman [AppSheet]) #2

@Hopp_Karla You could use a Valid_if on the report_id field in the form. It won’t hide the add button, but it will prevent the user from saving details for a reviewed report.

(Aleksi Alkio) #3

If you add a second REFROWS virtual column and then create a Read_Only slice as a source, you could toggle between these two inline views (show only one of them).