[SalesForce] IsChanged or IsNew

I had an interview recently, question was like : On update trigger a validation rule to check if entered amount is greater than zero.

I answered, we can achieve it by using ischanged formula field along with checking amount < 0 condition.

But interviewer said its not an apt solution, rather IsChanged, he said to use IsNew formula equal false + amount < 0 would be the solution.

But why not IsNew considered as a solution. Is my doubt????

Best Answer

If a record was initially created with a value less than 0 and that record was updated without that field being changed, a formula with ISCHANGED() wouldn't catch that the value is less than 0, but a formula with NOT(ISNEW()) would.

ISCHANGED() looks at a particular field to see whether that field has been changed.

ISNEW() looks at the entire record and whether or not the record is new.

Related Topic