Hi everyone, this is my first APP using Appsheet, so I appreciate your help with a problem I have.
Part of my App is an invoice with its detail, I have two tables, one of Invoice and the other Invoice_Detail. The two tables are linked to the ID_Invoice column. The invoice can have two states (valid, voided), I control the change of state with an Action and it works correctly.
In the UX section when I save an invoice, it takes me to the detail view and shows me at the bottom an inline form of the invoice detail with the buttons to view and to add new lines.
What I need is that if the status of an invoice is Voided, that the add line button does not show. To do that, in the Add action of the Invoice_Detail I wrote this condition:
LOOKUP([ID_Invoice],โINVOICEโ,โID_Invoiceโ,โStatusโ)=โvalidโ
The problem is that in any state of the invoice it hides the Add button.
Thanks your help!!!
Youโd likely want:
[_THISROW].[ID_Invoice] for your first parameter
(see #troubleshooting in LOOKUP() | AppSheet Help Center to understand why :))
Let me know it that works for you!
Hi Patrick, thanks for your answer, I already tried it like this but it does not work, the button is still not showing for any status of the invoice
Thanks for checking, I would be curious as to what would happen if you use <> โvoidedโ, would like to isolate the issue to whether or not itโs the lookup or the equality check thatโs problematic
if I use the condition:
LOOKUP([_THISROW].[ID_Invoice],โINVOICEโ,โID_Invoiceโ,โStatusโ)<>โvalidโ
The Add button is always showed
if I use the condition:
LOOKUP([_THISROW].[ID_Invoice],โINVOICEโ,โID_Invoiceโ,โStatusโ)<>โvoidedโ
The Add button is always showed
Hm then Iโm not so sure. One thing to try is to create a virtual column on invoice_detail that evalulates to LOOKUP([_THISROW].[ID_Invoice],โINVOICEโ,โID_Invoiceโ,โStatusโ) and see what that output looks like and make sure it matches your expectations
I have one virtual column to evaluate exactly your idea, and the values showed are OK, the data is correct in Invoice_Detail vs Invoice Status.
Is there any way to debug in appsheet? to know the data against which App be comparing the condition?
IF in your Invoice_Detail table, the column ID_Invoice is a Ref column, i.e. a pointer back to the Parent Invoice row, (by the way, if itโs notโฆit should be) then you can take advantage of โdotโ notation to retrieve the status and simplify the expression like this:
[ID_Invoice].[Status] <> "valid"
It seems you have ID_Invoice as a column in both tables? LOOKUP() is expanded into an ANY(SELECT()) combination of functions. I suspect that resulting expression is then experiencing some ambiguity with same column names and not finding the correct value.
The expression above is simpler anyway.
As a side note, I found a few places where when column names are the same across related tables you run into these ambiguity problems - templates are another one of those areas. I would recommend refraining from using the same column name in these cases.
Hello John, thanks your time.
I try your expression and other variations but the behavior is the same, the Add button does not show.
[ID_Invoice].[Status] <> โvalidโ
[_THISROW].[ID_Invoice].[Status] <> โvalidโ
If change condition the button is always showed.
[ID_Invoice].[Status] = โvalidโ
I checked the test expresion button with data population and expression results is correct, โVoidedโ status is FALSE and โValidโ Satus is TRUE, but the button does not show.
Any other idea?
Can you show us the column definition of ID_Invoice in your Invoice_Detail table? I think there might be something not set correctly there.
Behavior definition in INVOICE_DETAIL:
And the next images are about view
Hi Steve, thanks for your time.
I tested Legacy and Consistent option in this case and the behavior is the same.
The data in tables (INVOICE, INVOICE_DETAIL) are very simple, only 2 rows each one, and no BLANK data exist.
Following your suggestion in one of your posts I changed the expression using IN instead of =. I checked the Expression Test window and it evaluates the condition correctly, but in the App it doesnโt.
This:
[_THISROW].[ID_Invoice].[STATUS]
should be:
[ID_Invoice].[STATUS]
Wait, wait, waitโฆ
The Add action is not presented in a row context, so you cannot reference columns of the current row.
To do what you want to do, you arenโt going to reconfigure the Add action at all. Instead, you need to do the following:
Create a slice of the INVOICE_DETAIL table with no Row filter condition expression, and with Update mode set to Read-Only.
Add a virtual column to the INVOICES table called Viewable INVOICE_DETAILs and an App formula expression of:
[Related INVOICE_DETAILs]
For the Viewable INVOICE_DETAILs column, set Show? to the expression:
[INVOICE_ID].[Status] = "voided"
For the Related INVOICE_DETAILs column, set Show? to the expression:
[INVOICE_ID].[Status] = "valid"
See also:
Hi Steve,
I understand your idea but I tried and failed.
Both Viewable INVOICE_DETAILs and Related INVOICE_DETAILs show.
And Add action aslo show.
There seems to be no relation between slice and virtual column.
Can you post a demo app?
Thank you!
Why donโt you post what you have done? It seems like a better idea
This is my app demo.
I donโt know what step I did wrong in @Steve 's tutorial
Neither can anyone else if you donโt show us. Attach some screenshots from every step of the tutorial.
@Marc_Dillon
I have attached the link in #19?
Sorry, I didnโt check carefully!
Add button changed. But 2 column still show
Maybe this will help.
Step #5. Set the new VCโs โReferenced table nameโ to point to the new Slice.
Thank you!
I updated but nothing changed.
@Steve @Marc_Dillon
Thank you!
I found the answer at this link
P/S: App demo updated
User | Count |
---|---|
14 | |
11 | |
9 | |
7 | |
4 |