function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sourabh KhoslaSourabh Khosla 

Process Builder: Update parent record based on multiple criteria in parent and child records

Folks,
I have wrestled around this one for about one week.

I have a custom Parent Object where as soon as a button press happens, Status field on this custom object CH(C header) changes to processed. I want my rule(PB/Flow etc.)to fire when the CH.status==Processed, go to CL(C lines, basically similar to Opportunity Product lines), and check if any one of them have CL.Product2.Picklist ='picklist value'.... if yes, then go back to the CH(header)... and update the CH.IntegrationStatus='Ready'.
Is it achievable in a single PB, if yes how?
A. If I start from CH(modified or created)... I cannot choose any CL fields to check for the additional criteria... only CH fields are available as a criterion and CL are available for actions.

B. If I start from CL(modified or created)... it is not correct since CEL is never actually modified but CH is. Hence this logic itself is flawed to begin with.

C. I created a custom field at CL called CH's status ... created a PB to populate CL's status field every-time the CH status is changed to processed.. marking CL's record as modified and then using Step B. to check for CL.Product2.Picklist ='picklist value' {my criteria at CL) and then updating CH : CH.IntegrationStatus='Ready'.
So basically using 2 PBs, one to fire off a false 'modification' at line level when the status changes at header and other to check line level records and then update the CH.IntegrationStatus to ready.

This should have logically worked in theory but both of these PB ended up interfering with each other and now I am loss to understand how to even approach this problem.
NagendraNagendra (Salesforce Developers) 
Hi Sourabha,

I'm not 100% on this, but it sounds like you need a Rollup Summary Field. However, this has a minor twist because you also need to pull the product2 data down to the CL in order for the Rollup Summary Field to work. So...

Part 1

In your CL object, create a Process to copy the Product2.Picklist value to a text field on your CL object, on insert/update.

Part 2

In your CH object, create a Rollup Summary Field with a conditional count where CL.CopiedProduct2Value is whatever value you desire.

Part 3

In your CH object, create a Process that checks the Rollup Summary Field for a count greater than 0, and the Status is Processed, and then assign the value of Ready to the CH.

Realistically, I'd probably be tempted to accomplish this in code, because that's more moving parts than I'd want to use to use for something like this, but it's certainly doable. You just need two Processes, a custom text field, and one Rollup Summary Field, which isn't too bad. Note that you may also need to handle the situation where the Product2 value changes if that affects the related CL items, but that's a story for another day...

Hope this helps.

Thanks,
Nagendra