Happy Business Starts Here

Rethink how you sync deleted products in Zuora to Salesforce

0 Kudos

Rethink how you sync deleted products in Zuora to Salesforce

Check out this trigger. It has a literal Zuora ID in it. Why? This product, named "test", was created in Zuora, and deleted. You can't find it in Zuora either through the UI or through a query or export. But it still exists, and zuora 360 still tries to sync it to SFDC. It throws an error because Product2.DurationDays__c is a required field. I had to add this kludgey stuff to my trigger in order to prevent the Zuora Product sync from reporting an error every time.


I can't make the product actually go away, and I can't edit the Zuora_Duration_Days__c field in Zuora. The only way I could figure out to suppress the sync error is this kludge in the SFDC trigger.



// Zuora needs DurationDays__c to sync, but it cannot sync to a number field
// So we sync Zuora to Product2.Zuora_Duration_Days__c and this trigger syncs that to Product2.DurationDays__c

trigger ZuoraProduct2Trigger on Product2 (before insert, before update) {
    for (Product2 p : Trigger.new) {        
        try {
            if (System.UserInfo.getName().toLowerCase().contains('zuora')) {
                if (p.Zuora_Duration_Days__c == Null && 
                    (p.zqu__EntityID__c == '2c92a0fd55822b48015583181b0250e6' || p.Name == 'test')) {
                    // test product, deleted in zuora, but still gets synced 
                    p.DurationDays__c = 0;
                else {
                    p.DurationDays__c = Integer.valueOf(p.Zuora_Duration_Days__c);
            else {
                p.Zuora_Duration_Days__c = String.valueOf(p.DurationDays__c);
        } catch (Exception e) {
            p.addError(String.format('Product "{0}" "{1}" error converting Zuora Duration Days "{2}"', 
                new List<String>{p.Name, p.zqu__EntityID__c, e.getMessage()}));


Zuora Alumni

Hi @bolaurent


The reason behind this design is that this would ensure that existing quotes on the SFDC org would not be broken and would still reflect the correct products and product rate plan charges. 

Soft deleted products -- these are the products in Zuora that are deleted in the web UI. They are not visible on the web UI but are still in existence on the database.
If Soft deleted ZProducts are also deleted in your SFDC org, they will be synced back to the same SFDC org whenever a Product Catalog sync is performed in Z-Billing.

Currently, there's no way to fully delete these "soft deleted" products in Zuora.


We now have a T9 feature "Stop sync deleted product"


If this feature is enabled , it will prohibit the syncing of Deleted products from Zuora to Salesforce. 


This feature does require Engineering approval, please let me know if you would like us to enable the same?



Thank you so much!


I don't want to stop this behavior in a blanket sense. I want to delete this one record which is causing sync failures, and which I know I don't need to keep around for data integrity purposes.