- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Email to a Friend
- Printer Friendly Page
- Report Inappropriate Content
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()})); } } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.