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
VirturionVirturion 

If statement with single value

How do I create an If statement in a Formula Field that only has a single value. I've illustrated an example of what currently doesn't work below.

 

IF( AND(OwnerId <> "00000000000000", ISPICKVAL(Status, Something) ), Now() - Case_Age__c, )

 

 

Thanks

flewellsflewells

What error message are you getting when you try to save? 

 

It looks like you want to display nothing if it doesn't meet your criteria...instead of leaving it blank, try replacing with "" or NULL.

VirturionVirturion

Actually thats the problem. I want to calculate up until a certain point. Once the conditions of the If change I don't want to overwrite the previous value.

 

The error is... Syntax error. Found ')'

 

I think I understand the error, I'm just not sure of the correct syntax or function to use in this instance.

 

flewellsflewells

Hmmm, I think I misunderstood, but still not clear on what you're trying to achieve. 

 

You wrote "once the conditions of the If change I don't want to overwrite the previous value".  This makes me believe that a formula field may not be the right solution for you, but a workflow field update might be.  There's no such thing as a previous value for a formula field -- it always reflects the result of your formula based on the current values on the record.

VirturionVirturion

Thats what I was afraid of. The ultimate goal is to calculate the time difference between Case creation and the Case being handled by an agent. My initial thought is to simply use a field called Age and an Event like a selected value from a drop down field to calculate the age. However the syntax requirements of the IF get in the way as I do not have any alternative value.

 

I assume, short of externally coding a trigger, there is no way around this?

flewellsflewells

What about formula that calculates age based on the closed date/time (if already closed) and current date/time (if still open) provide that alternate value?

 

As for the actual formula syntax, this posting may help (admittedly more complex than suggestion above) - http://community.salesforce.com/sforce/board/message?message.uid=29912.

VirturionVirturion

I was able to resolve this by using a combination of a Formula Field and Workflow Rules with some custom formulas.

 

Thanks for the help!