I have created a workflow on the Order Line Item object that fires when a custom field named Customer Budget is Changed. I have added 3 field update actions under this workflow rule.
- To update a Custom field named Remainder Quantity
- To update a Custom field named Remainder Amount
- To update the standard Quantity field.
The User enters a value to the
Customer Budget field, and that value will be divided by the value in the Standard
Unit price field. And whatever the value we get by that function will be updated in the Standard
Quantity field i.e that 3rd field update action that I have mentioned above.
After the Quantity is updated, the Total field will be auto-calculated with the logic of Unit
UnitPrice * Quantity. The difference between the Customer Budget field and the Total Price field is updated in the Remainder Amount field using the second field update action.
The first update action just checks if the difference between the Remainder amount and customer budget field is positive and updates the Remainder Quantity field.
My problem here is when I enter the Customer Budget as 1350. The field values are as mentioned below.
Customer budget = 1350
Unit Price = 45
Quantity => 1350 / 45 = 40
Total price = 1350
Difference between Customer Budget and Total price = 0
But even though the difference is 0, and the same should be updated in the Remainder Amount, I am seeing the value of 765.
The formula that I've used to update the Remainder Amount is as below. I have used
Quantity * UnitPrice because I couldn't reference the Standard Total price field. And I had to use the logic of it instead.
Customer_Budget__c - (Quantity * UnitPrice)
I am not sure why this is happening, Is it because the three field update actions are firing randomly instead of in Order? If yes, how can I go around this? can anyone please help me with this? Thanks in advance. Also, please let me know if further clarification is needed for this.