Happy Business Starts Here


Sync Billing Account custom field from Salesforce to Zuora

I would like to

1. have custom field on Billing Account to keep "additional emails" (text field)

2. have a 2-way sync


I already created field in Zuora under Customer Account, and in Salesforce under Billing Account with the same API name.


When I update that field in Zuora - new value syncs back in Salesforce.

But when I update that field in Salesforce (in Billing Account) - it doesn't sync back to Zuora.


Question: how can I sync back values from Salesforce to Zuora?
Is there any native way?


Or do I need to do it by my own via Apex trigger via Order Buider API?


I've read in one of the posts 2 years ago that  "Salesforce Account data is sent to Zuora only when it is a NEW Subscription with a NEW Billing Account"

Did anything change since then?

Tags (2)
Zuora Support

Re: Sync Billing Account custom field from Salesforce to Zuora

@mporset If I understand correct when you say: how can I sync back values from Salesforce to Zuora? Are you referring to the quote creation process for a NEW Subscription with a NEW Billing Account.


If yes, then you need to create the custom field on the Salesforce Account as well with same API name. Salesforce Account custom field values are used to populate custom fields on the newly created account in Zuora.


Related KC article: https://knowledgecenter.zuora.com/CA_Commerce/C_Zuora_Quotes/CA_Configuring_Z-Force_Quotes/D_Configu...


Please let me know if this helps.

If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √


Re: Sync Billing Account custom field from Salesforce to Zuora

What you need to do is to write or add to a BillingAccount__c trigger and detect when the change is made and then queue up a method to update it in Zuora.

You will need to check to see which salesforce user made the update because you do not want to update Zuora from a sync update.  So if your Zuora Sync User made change ignore.

Maggie Longshore

Re: Sync Billing Account custom field from Salesforce to Zuora

Jyoti_Sinha: I already pointed out that I have a field created on Salesforce and Zuora with the same API Name but it only syncs one way.


MaggieL: Thank you for your answer. I was just hoping that can be achieved in native way. Thanks for pointing out that I need to filter out updated made by "Zuora Sync User".


I've found a useful piece of code I can use for update:


Re: Sync Billing Account custom field from Salesforce to Zuora

Yes there is no native way to update the Customer Account object outside of the fields included with the quotes.


Here is code I use if you want some different ways of looking at it.


I handle this in a separate method because I call this for different types of objects - not just Account, I accommodate running from tests and I also let the caller decide on whether they want to treat a non success response as an exception.  some of the code is specific to my code base but it will give you the idea.


I intentionally do not swallow the invalid field exception in this method.  I want to know when these occur so I can fix the code or update the wsdl. The calling methd is usually a part of a process that would notify me of errors or log them to a custom log object. 

// method to send a list of updates to Zuora, used by a queueable call from account trigger and others
	private static void UpdateZObjects(List<Zuora.zObject> objs,                                          
	                                   String objectName,                                                 
	                                   Boolean throwException){                                           
		zApiInstance = zoqlUtils.zApiInstance;                                                            
		if (objs == null || objs.isEmpty()){                                                              
			System.debug( '### No data objects.');                                                        
		System.debug( '### objs '+ objs);                                                                 
		List<Zuora.zApi.SaveResult> results;                                                              
		String s_message = '';                                                                            
		Boolean success = true;                                                                           
			results = zApiInstance.zupdate(objs);                                                         
		else {                                                                                            
				results = new List<Zuora.zApi.saveResult>();                                              
				Zuora.zApi.saveResult testSaveResultSuccess = ZuoraZApiInstanceFactory.saveResult();      
				//Zuora.zApi.saveResult testSaveResultFail = ZuoraZApiInstanceFactory.saveResult();       
				//List<Zuora.zObject> errors = new List<Zuora.zObject>();                                 
				//Zuora.zObject error = new Zuora.zObject('Error');                                       
				//error.setValue('Message','Error Message for Test');                                     
			System.Debug('### SOAP Results '+ results);                                                   
			for (Zuora.zApi.SaveResult result : results){                                                 
				if (result.success == false){                                                             
					if (result.errors != null){                                                           
						for (Zuora.zObject error : result.errors) {                                       
							success = false;                                                              
							s_message += error.getValue('Message') + ' | ';                               
							System.debug('### result error ' + error.getValue('Message'));                
			if (success == false && throwException){                                                      
				throw new zoqlUtils.zoqlUpdateException('Unable to update ' +                             
				                                        objectName +                                      
				                                        ' objects in Zuora, error was ' +                 
Maggie Longshore

Re: Sync Billing Account custom field from Salesforce to Zuora

Thank you for sharing your code, it's very useful.