I feel I should know this but just not coming up with a solution.
I want to simulate the REF_ROWS() function but need to select rows by more complex criteria than matching columns between the two tables.
Here is my use case:
I have Products, Options and Customer Discount tables. My goal is to show a Product Pricing view and show all of the information that can affect the final price of that product - Base product price, Option Prices and all relevant Discounts. However, while some Customer Discounts are by an individual product, others are a Discount that applies across the board to all products.
So, I want to create a Virtual Column that pulls ALL discount records together and not just match by the Product I am currently viewing.
I can create this VC with no problem but now I want to display it as an Inline Table and not just a list of ID’s. Is there a way I can do that?
Instead of creating your VC in the parent table as a LIST of child records, try adding a VC of type Ref to the child table and let AppSheet create the REF_ROWS() for you in the parent table.
For this to work, you may need to add a column to the parent table to store a ‘query’ so that the child records’ VC will find and match to that parent row.
Thanks @Steve! Just needed to update the List Element Type to Ref. If I had only looked more closely at a REF_ROWS() column!!
A follow-up question. For a REF_ROWS() displayed Inline Table when clicking the “Add” button under the table it somehow knows to pre-populate the “Parent” (though not a formal parent/child relationship) table record ID into the associated Form.
This same behavior does not happen for Inline table displayed for my custom Virtual Column. I know I can use a LINKTOFORM() action and attach to Row Selected behavior. But, is there some easier way to make that happen you are aware of? I mean, it happens automatically for the REF_ROWS() VC’s.
REF_ROWS() must be used to get the column auto-populated using the Add button of an inline view.
[Auto-fill parent ref in child from inline table?](https://community.appsheet.com/t/auto-fill-parent-ref-in-child-from-inline-table/29414/5) Questions
After some experimentation, I’ve found that if REF_ROWS() is the entirety of the column’s App formula expression, the Add button in the related inline view will auto-fill the column referenced in the REF_ROWS() expression in the new row. To retain this magic, the REF_ROWS() results cannot be modified in any way, such as by list addition or subtraction, or with SORT() or ORDERBY(). Magic: REF_ROWS(…) (REF_ROWS(…)) Not magic: REF_ROWS(…) + LIST(…) REF_ROWS(…) - LIST(…) SORT(REF_R…