You need to sign in to do that
Don't have an account?
Laura Babb 4
add priorvalue with new value being updated from process builder
I have a field that on Opportunity Product object (Quantity Used) that I update via process builder using a field reference to a field on a custom object (Quantity Used). The field update on Opp Product is then used to formulate the Quantity Remaining by subtracting the Quantity Used from the Quantity sold on the line item. The issue I'm having is that it obviously overwrites each time instead of adding the prior value of Quantity Used with the new amount to formulate the true number of used and remaining. Please tell me there is a way to accomplish what I need! TIA, developers!
The custom object,(Quantity Used), is it a many to one relation to the Oppty Product Object? and that is where the problem lies? i.e. the first Qty Used Record is created and updates the field correctly and then when the second Qty Used record is created, it overwrites the value rather than updating?
If that is what you are chasing, then you "could" use process builder, but I would be wary of the results.
Update the Process builder on the Quantiy Used Object to use the ISNEW() and then update the field on the related Oppty Product record using a formula like PRIORVALUE([OpportunityProduct].QuantityUsed__c) + [QuantityUsed].QuantityUsed__c
Then your field Quantity Remaining can be a formula field subtracting the other fields, and would not need an additional DML activity to update.
Note, with the above, the Opportunity Product field Quantity Used would need to have a default value of zero, (adding to blank fields doesn;t always work).
Note, I would be wary of the Process Builder option above because it would not recalculate if any of the Quantity Used records are deleted. Hence, a trigger would be more robust.
Hope the above is helpful
Regards
Andrew
So the data model is:
Oppty Product is a lookup to Opportunity.
Data Feasibility Request (DFR) is (lookup) related to the Opportunity.
And there is a link between the DFR and the Oppty Product (probably a lookup).?
IF there is only ever one DFR, then it is OK for the process builder to overwrite the value of Quantity Used on the Oppty Product.
Make your Quantity Remaining field on the Oppty Product a formula field (Quantity Sold - Quantity Used). (don't use a process builder to update the Quantity Remaining field as that complicates things).
IF there are multiple DFR, then update the Process builder on DFR to use ISNEW() in the criteria, and set the IA to update the related Object (Oppty Product). And the field Quantity Used to be a formula as noted above:
PRIORVALUE([OpportunityProduct].QuantityUsed__c) + [DataFeasibilityRequest].QuantityUsed__c
Ensure the number field QuantityUsed__c on Oppty Product has a default value of zero.
IF there is only ever one DFR but you would like the Quantity Used field or the Quantity Remaining field on the Oppty Product to be directly editable, then we need to rethink things.
Hope that makes sense
Andrew