Hello everybody!
I have this problem that keeps reoccuring when I’m working with appsheet. English is not my native tongue, so apologies for any grammatical errors 
My case is that I have a Customers(Customer_ID) table, related to that I have a customer_site table and a customer_contact table.
Then I have a table for order_confirmation. All three tables above are “going into” the order_confirmation, but “customers” is the parent to “customer_site” and “customer_contact”.
When you create a new order_confirmation, you first choose or add a customer, then you choose or add the site and contact related to the customer.
My problem is that inside the order_confirmation table there is no referance between the three customers tables, so when I choose or add the customer first, there is no relation to the customers table. So the “site” and “contact” is kind of on their own. So when I e.g make a new site in the order_confirmation view there is no relation to the CustomerID
I’ve looked into ref_rows(), but I don’t understand how to use it.
Can anybody give me a push in the right direction?
It’s very hard to explain my problem, so let me know if there is anything else I can add, to make it more understandable.
Order_Confirmation table:
I’m starting to realize that it might not be feasible to do it this way.
Because the Customer_ID won’t be created before the row is saved. And therefor it’s not possible to relate neather site og contact to the “Customers” table.
Am I wrong?
Hey man,
you can do it in the FormSave Event with an Action
Cheers
How will you acomplish that?
I guess the Customer_ID won’t be created before you save the form?
I’ve done some testing, and got this “Initial Value” and “Suggested values”
(Just giving out info, so somebody might have a clue
)
Initial Value (Customer_Site_ID):
This will give me the top/index 1, attached/related site for this customer if they exists, or it will show the site input in this form.
if(isblank([Customer_Site_ID]),
if(
count(select(Customer_Site[UID],[CustomerID]=[_THISROW].[CustomerID]))
>
0
,
index(select(Customer_Site[UID],[CustomerID]=[_THISROW].[CustomerID]),1)
,
[Customer_Site_ID]
)
,
[Customer_Site_ID]
)
Suggested Values (Customer_Site_ID):
This will just put out related Customer_Site’s to the CustomerID
filter("Customer_Site",[CustomerID]=[_THISROW].[CustomerID])
This doesn’t do shit about the problem
but it might be a little easier to understand how I’m working.
Thank you for the effort!
Can you explain me what “-1” accomplishes in this code?
INDEX(SELECT(order_confirmation[Customer_ID], ([customer_contact_ID].[Customer_ID] = "-1")), 1)
Now I tried to set it up like your app, but there is still no generating of CustomerID.
I found the “-1” 
Still this doesn’t give me a result, it seems there’s something wrong about the code.
INDEX(SELECT(order_confirmation[Customer_ID], ([customer_contact_ID].[Customer_ID] = "-1")), 1)
Now the column becomes “-1”. It looks like the action doesn’t run on the site and contact table.
Hey,
make sure to also check out the FormSaved Event in the order_confirmation_Form and the Actions involved, without them it wont work.