What I'm looking to do is be able to add the product with all of the other products, and update the price when the total price changes. Almost like a trigger.
Here is my process:
Is there a way for this to update without adding in the line item after the other products have been added? Or is this something a trigger would be better suited for? I'm guessing since the Total Price of the quote isn't generated until the products are added, it doesn't have a value until the quote items have been added.
답변 1개
Hi Josh,
No, you cannot do this with process builder. If you create another process on quote that would update the surcharge whenever the price changes, then the surcharge itself will be calculated incorrectly as the price will include the previous value of the surcharge.
What you need is a mechanism that counts the total amount of non-surcharge items, and calculates the surcharge based on that.
You might be able to do this with a record-triggered flow on the line item. Every time a line item is created, or its price changes, you'll want to query all items in that quote that aren't the surcharge. Add them all up into a variable.
Next, query for the surcharge row. If found, update it with the new surcharge calculation. Otherwise, create a new surcharge row.