In your specific use-case, it looks like you are trying to filter/find Invoices by Customers on the UI.
Does this web service allow you to search invoices by internal ID, c4c customer UUID, or external ID?
The below design assumes that your webservice can handle searching invoices by C4C customer internal ID/ C4C customer UUID.
The design/code pattern to "join" two BOs together in code is the following
The Invoice BO will be your "Target", meaning you will bring data from a "Source" which will be the "Customer BO"
1. In your Target store some some sort of key to get the Source BO. In your case will be either the UUID or Internal ID of the customer.
var CustomerID = this.CustomerID_Z
2. Depending on the BO, sometimes you will be able to retrieve the BO by internal ID. You will always be able to retrieve a BO by UUID. Use the retrieve function to get the BO. Like you did above
var CustomerBOTemp = Customer.Retrieve(CustomerID);
***
If the BO does not allow you to Retrieve by Internal ID, then you would need to construct a query to get the customer data by Internal ID such as this, then do a for loop, and once it finds an instance then set the association and exit the loop
//query the Customer BO to get the account related data
import AP.FO.BusinessPartner.Global;
var query_account;
var account_selparam;
var account_instance;
var query_account_result;
query_account = Customer.QueryByIdentification;
account_selparam = query_account.CreateSelectionParams();
account_selparam.Add(query_account.InternalID,"I","EQ", this.CustomerID);
query_account_result = query_account.Execute(account_selparam);
foreach(account_instance in query_account_result) {
this.ToCustomer = account_instance;
break;
}
***
3. Now that you have the CustomerBOTemp you can then access it to set whatever you need on the BO. For example, if you wanted to set your Customer association, then it would be
this.ToCustomer = CustomerBOTemp;
I am assuming you want to display the joined Customer BO data with your Custom Invoice BO, then do step 1, 2 and 3 in your after modify script.
4. Now that you have the association set, then you can display the joined data on your UI. Since step 1 stores the CustomerID as a FK on the Invoice header, then it will be a 1:1 relationship between Invoice and Customer or 1:M relationship between Customer and Invoices...
Open the UI designer create a UI (TI, OWL, QV) on top of the Invoice BO and then just drag and drop the ToCustomer UI elements directly on to the UI since it is a 1:1 relationship.