0

I have formula fields which calculates the net value and total value for sales order object, I want to change these formula fields values but not affect the old value for sales order which is packed, how to do that? I thought about setting a date and time in the formula field and compare the packing time with these date and time, if it is old and packed then the formula value is the old one, if it is newer then calculate it based on the new one, this looks a bit weak, any suggestions?

  • Why not going for workflow field update? It will give you the flexibility to set complex conditions based on what you want to update the field. – sanket kumar Oct 19 '18 at 7:37
  • Because I will write the same code in workflow and it will become more complicated since I have to add a workflow, by changing the formula field only we have simpler and less code, however my questions is: is there another way rather than comparing dates? – Roody Oct 19 '18 at 7:46
  • Actually, workflow will not solve the problem I guess because formula fields are calculated in run time, workflow can't change those values every time looking to those fields since they are not edited (read only) – Roody Oct 19 '18 at 8:29
0

If you want a formula which will calculate different data, you should create a new field. Trying to store two different data points in the same calculated field is a path to madness.

If you are determined to store both values in one field, it would still be better to preserve the old calculation and add the new calculation in a separate field. You can then add a third formula for output purposes.

If you want to preserve historic data, you will need a writeable field and workflow rule, as suggested in the comments. That's what I gathered from your original post, but based on your own comments I wrote the above instead.

0

I solved it by using a date field in the formula field like this:

IF(CONTAINS("USD;CAD:US",text( CurrencyIsoCode )),Net_Order_Total_From_Quote__c, Case (text( CurrencyIsoCode ), "SEK",*IF(PBSI__Packing_Date__c>Date(2018,10,18), Net_Order_Total_From_Quote__c-(0.25*Net_Order_Total_From_Quote__c), Net_Order_Total_From_Quote__c) ,* "EUR",(Net_Order_Total_From_Quote__c )/ (1 + $Setup.VAT__c.Belgium_VAT__c) , "GBP",(Net_Order_Total_From_Quote__c ) / (1 + $Setup.VAT__c.UK_VAT__c), 0)) ...... the rest of the formula

0

Comparing dates will be fine you can use below code by putting your appropriate fields and formulas to calculate net value.

eg.

if( DATEVALUE(CreatedDate) >= DATE(2018,10,19),1,2)

you can replace 1 & 2 with your formulas, no need to use DATEVALUE if your field is date type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.