Tuesday, April 23, 2019

Cross-Object Formula Field Not Visible as a Filter for My Roll-Up Summary Field

I ran into some issues this week, trying to add a Roll-Up Summary Field on the Order Object. Specifically, I had recently added a cross-object formula field to the Order Products object, and I was trying to determine how many Order Products of a specific type (Hardware) were associated wiht the order. Here are the details and the work around I learned (with a little help from my friends):

OBJECTIVE: Track the number of hardware products that had been added to an order.

BACKGROUND: I'm adding the ability to track customer orders through the order fulfillment process for one of our Salesforce teams.  We're using the standard Order object, and associating Order Product records to that order.

Setting up a field to track the total quantity of products (Total_Product_Qty__c) that were on the order was straight forward: a simple roll-up summary field on the child OrderProduct.Quantity field did the trick.



In the Product2 object, we use the Family field to distinguish what type of product that item is (Hardware, Subscription, Service, etc.).


I thought the process for setting up a roll-up summary field on the Order object, getting a count of all Order Objects that were of type Hardware would be straight forward: I set up a cross-object text formula on the Order Product (OrderItem) object to pull in the Family field from the Product2 object (i.e., the OrderItem's related PricebookEntry.Product2.Family).

I created the cross-object formula field on the Order Product object with no issue, but when I tried to add a roll-up summary field on the parent Order object, using that new cross-object formula field as a filter, the cross-object formula field wasn't visible as a selectable filter.

Admin Secret: 90% of being a Salesforce Admin is having strong skills in Google Fu, the art of finding information you need from somewhere else out there on the web.

I googled "can't do a roll-up summary of custom fields on order product object" and found this article by Ariel Ward, with solutions by Steve Molis and Narender Singh. The gist of it boiled down to the fact that you can't use cross-object formulas in a roll-up summary field.

THE SOLUTION: I kept the formula field on the Order Product object, but added a custom checkbox field (HW) to the object, as well. I used a Process Builder flow to set the checkbox to True if the cross-object formula field had a value of "Hardware".

This checkbox field was selectable as a filter on the parent Order's roll-up summary field, so I was able to add a "Total_HW_Product__c" as a roll-up-summary field on Order Product > Quantity, with a filter of HW == TRUE.



No comments:

Post a Comment