Happy Business Starts Here

Highlighted
Tutor

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)
7 REPLIES 7
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 √

Guru

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
Tutor

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:
https://knowledgecenter.zuora.com/CA_Commerce/I_Development_Resources/B_Order_Builder/D_Programming_...

Guru

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.');                                                        
			return;                                                                                       
		}                                                                                                 
                                                                                                          
		System.debug( '### objs '+ objs);                                                                 
                                                                                                          
		List<Zuora.zApi.SaveResult> results;                                                              
		String s_message = '';                                                                            
		Boolean success = true;                                                                           
                                                                                                          
		if(!Test.isRunningTest()){                                                                        
			results = zApiInstance.zupdate(objs);                                                         
			logCurrentCallout('UpdateZObjects');                                                          
		}                                                                                                 
		else {                                                                                            
                                                                                                          
				results = new List<Zuora.zApi.saveResult>();                                              
				Zuora.zApi.saveResult testSaveResultSuccess = ZuoraZApiInstanceFactory.saveResult();      
				testSaveResultSuccess.success=true;                                                       
                                                                                                          
				results.add(testSaveResultSuccess);                                                       
                                                                                                          
				//Zuora.zApi.saveResult testSaveResultFail = ZuoraZApiInstanceFactory.saveResult();       
				//testSaveResultFail.success=false;                                                       
				//List<Zuora.zObject> errors = new List<Zuora.zObject>();                                 
				//Zuora.zObject error = new Zuora.zObject('Error');                                       
				//error.setValue('Message','Error Message for Test');                                     
				//errors.add(error);                                                                      
				//testSaveResultFail.errors=errors;                                                       
                                                                                                          
				//results.add(testSaveResultFail);                                                        
			}                                                                                             
                                                                                                          
			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 ' +                 
				                                        s_message);                                       
			}                                                                                             
		}                                                                                                 
                                                                                                          
	}                                                                                                   
Maggie Longshore
Tutor

Re: Sync Billing Account custom field from Salesforce to Zuora

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

Student

Re: Sync Billing Account custom field from Salesforce to Zuora

Hi Mporset,

 

We have similar requirement where we need to update Bill To and Sold To Address fields from Salesforce to Zuora. Can you please let me know the implementation you did for this requirement as I am new to Zuora Environment.

Student

Re: Sync Billing Account custom field from Salesforce to Zuora

Hello MaagieL,

 

I have similar kind of requirement where I have to update the Bill to And Sold To Adress fields which are updated at Salesforce End and those changes should reflect to Zuora. LEt me know if similar code can be used.