function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Haseeb Ahmad 9Haseeb Ahmad 9 

Need help to update a field on order object

Hello,

I have a related list on account object called " Billing Accounts " (zuora__customeraccount__c).

One account record can have multiple billing accounts records.

On the order object, we have a field called "billing instance" (Billing_Account_Instance__c) which is a lookup to the "billing account" (zuora__customeraccount__c) object.

Currently, users have to populate this field once the order is created.

Now what I am trying to solve is if one account has one billing account populate that billing account in that field once the order is created. 

But if multiple billing accounts exist then not do populate anything so our billing team can choose the most appropriate billing instance for that order.

Can I get some guidance on how I can do that, thank you. 
 
AnudeepAnudeep (Salesforce Developers) 
Hi Haseeb - I recommend leveraging process builder to achieve this
Haseeb Ahmad 9Haseeb Ahmad 9
Hi Auudeep,

Thank you for your help but I think there is some confusion so let me explain in better words.

Account object has no relationship with a billing account object (zuora__customeraccount__c) that object come from a zuora 360 manage package and only exist on account object as a related list.

Once we create a customer account in zuora with the same account name as in salesforce it push to salesforce and it links to that record's related list as billing account.

That said one account record in salesforce can have multiple billing accounts is zuora which means more than one billing account can be linked to one account record in salesforce.

Now on the order object, we have a field called "billing instance" (Billing_Account_Instance__c) which is a lookup to the "billing account" (zuora__customeraccount__c) object.

Normally when we create an order for the billing account we have to update manually in that field.

So my ask is if an account record has only one billing account in the related list, populate that in "billing instance" (Billing_Account_Instance__c) in order but if there are multiple billing accounts on one single account record don't do anything and the user will pick up billing account on order object later manually.

I hope it is much clear now, what I am trying to achieve. 
leonardokipperleonardokipper
How you identify the Account when the Order is created? It have a field with the Account id or a lookup direclty to the Account?

Then it will be possible query the related Billing Accounts of that Account and check if the list contains only one or more records to populate your Billing Instance lookup field.