Set Variable [$CustomerID ; value: Customer::CustomerID ]
Go to Lay-out ["Company" (Company)]
New record/new request
Set Variable [$CompanyID ; value: Company::CompanyID]
Go to Lay-out ["Customer_Company"(Customer_Company)]
Set Field [Customer_Company::CompanyID ; $CompanyID]
Set Field [Customer_Company::CustomerID ; $CustomerID]
Go To Layout [original layout]
This way you create a new company record and then also a matching Customer_Company record that links the current record on your Customer Layout to that new company record. If you have fields from Company in your Customer_Company portal and permit entry into them while in Browse mode, you can click your new company button and then fill in the fields in the new row that appears in this portal.
Thanks, but now i get a error that the field Customer_Company::CustomerID can't be empty.
If i say that it's allowed to skip the field i don't get the result i was looking for.
How do i solve this?
That error message should not be appearing as That field gets a value in the 8th line of the script.
Make sure that this script is run from the Customer layout not the company or customer_company layout. Make sure that the current record on that layout is the one to which you want to link the new join record and new company record.
Line 2 captures the CustomerID of the current customer record in a variable and in line 8 puts it in the join table.