function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mitchell McConnell 2Mitchell McConnell 2 

can a formula behave differently for NEW vs UPDATE

I have a formula for a custom field on a custom object that uses "ISBLANK" to set a field differently based on whether or not the field is set.

However, I also want users to be able to modify the same record at a later time.  At that point, I do not want that exact logic, or at least I want to make sure it bhaves slightly differently.  When I tried to use ISNEW in the original formula, it gave me an error: "Function ISNEW may not be used in this type of formula".

So I am not sure how to accomplish what I want.

If ISNEW would work here, I think the logic is pretty straightforward.

Is there a way to make the formula use an Apex method?
 

Best Answer chosen by Mitchell McConnell 2
Boris BachovskiBoris Bachovski
You can't create a different formula for NEW or UPDATE. Formula field is executed on runtime and they don't evaluate before the record is created or before it's updated.

The ISNEW() function that you're trying to use can be only used when creating a workflow.

And unfortunately there is no way to call apex method from a formula field. Alternatively you can move the formulat field logic into a trigger and populate a text/number field on the record directly from the trigger.

All Answers

Boris BachovskiBoris Bachovski
You can't create a different formula for NEW or UPDATE. Formula field is executed on runtime and they don't evaluate before the record is created or before it's updated.

The ISNEW() function that you're trying to use can be only used when creating a workflow.

And unfortunately there is no way to call apex method from a formula field. Alternatively you can move the formulat field logic into a trigger and populate a text/number field on the record directly from the trigger.
This was selected as the best answer
Mitchell McConnell 2Mitchell McConnell 2
Boris, thanks for the reply.  That is more or less what I figured I would have to do.