1

I have a Process Builder that I created which is working fine in my lower sandbox but is throwing a CPU Limit error when deployed to production. I have used IsChanged in the process builder. I think whats happening is that each time a value in the component is changed, it executes the calculation, but when the component is changed, it always evaluates to true so I think it is entering a recursion loop. Is my theory correct? Do I need to modify the process builder to make this work. Basically what I am trying to do is when a component in an equation is changed or modified then the "Rating" field is recalculated and updated. I have attached some pictures of my process builder enter image description here

AND(
    NOT(ISBLANK([Opportunity].LPP_Rating__c )),
    TEXT([Opportunity].Collection_Status__c) <> "Open",
    [Opportunity].Retake__c = false,
    OR(
        ISCHANGED([Opportunity].Total_Payments__c), 
        ISCHANGED([Opportunity].Sales_Tax_Rate__c),
        ISCHANGED([Opportunity].Reorder_Payments__c),
        ISCHANGED([Opportunity].Total_Production_Value__c),
        ISCHANGED([Opportunity].Discount__c),
        ISCHANGED([Opportunity].Children_Photographed__c),
        ISCHANGED([Opportunity].Commissions_Paid__c)
    )
)

enter image description here

The formula is basically several if else statements (if equation is greater than .62 then update Rating fiels to "A" and so forth). I intially had selected "No criteria-just update the records." I changed it to updated records meet all conditions" Can you please let me know if this should finish the CPU limit error and if I should modify it further? Thanks

1
  • It's cool to see that PB can drop CPU time limit. Can you rewrite it with trigger? How many workflow updates do you have for opportunity object ? Commented Apr 3, 2019 at 18:45

2 Answers 2

2

This can all be achieved with a custom formula field (see how to create one here) and you can avoid Process Builder altogether.

Add all these conditions to the formula field, and anytime conditions don't match properly, you can put the value as null so it'll be blank for situations in which there shouldn't be a rating.

If you need this rating to be static and unchanging at the time it's set (and not always updating with changing conditions), have the same formula field in the background (i.e. take it off any of the page layouts) and use Process Builder to simply set the normal Rating custom field to the Calculated Rating custom formula field.

4
  • Hi Brian, the "Rating" field needs to be updated everytime someone changes the values of the fields that comprise of the equation for contribution margin Commented Apr 3, 2019 at 19:47
  • Then all you need is the formula field itself :-) Note: you can run into a limit of a formula field being too large at compile time, but this usually only comes up with really complex logic or traveling across multiple lookup fields / other formula fields Commented Apr 3, 2019 at 20:37
  • Can we use conditionals in formula field? So basically if the formula comes to be let’s say 90, we need to update rating to A, if 80, update to B and so forth Commented Apr 3, 2019 at 21:02
  • Yes! The formulas you see and are able to build in Process Builder mimic the Custom Formula Fields capabilities. Formula fields came first :-D Commented Apr 4, 2019 at 6:47
-1

Simple answer - Don't use PB

PB is a fancy tool that can leverage Workflow field update logic. However tool is not perfect and might cause issues, especially when used on vital SFDC object as Opportunity. I suspect that you have multiple managed packages on top of Opportunity object or multiple workflow updates. Even Dan Appleman doesn't recommend to use PB, cause its slow and unpredictable.

Try to replace it with:

  • before trigger if you need to update source object.
  • formula field if answer is based on oppty fields
1
  • 2
    There are appropriate use cases for Process Builder. I'm not sure I see enough information in the question to justify writing it off here.
    – David Reed
    Commented Apr 3, 2019 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .