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
Abhishek Singh 88Abhishek Singh 88 

formula field do nothing

Hi All,

I have a formula field called as "Number of days breached" which have formula
RCA_dueDate__c-NOW()
I want this formula should run only when RCA status is apprved somthing like this
IF(RCA_status='Approved',RCA_dueDate__c-NOW(),do nothing)

i tried this way
IF(RCA_status='Approved',RCA_dueDate__c-NOW(),Number_of_Brached_days__c)

But it gave error.

Any help would be appriciated​​​​​​​
 
Best Answer chosen by Abhishek Singh 88
Khan AnasKhan Anas (Salesforce Developers) 
Yes, I have put null for the false condition. In the formula field, you cannot refer to the field's previous value. If you want to do nothing in else condition then you need to change the field type of Number of days breached, from formula to number and update this field using process builder or trigger.

Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Abhishek,

Greetings to you!

You can try below formula:
Number of days breached (Number) =
IF(ISPICKVAL(RCA_Status__c, 'Approved') , RCA_DueDate__c-NOW(), NULL)

I believe RCA_Status__c is a picklist field and RCA_DueDate__c is Date/Time field.

If RCA_DueDate__c is Date field then you need to use TODAY() instead of NOW()

Note: Salesforce formulas don't store data; they are calculated fresh each time they're viewed. Your formula field cannot store or retain its own previous value. 

if you want to do nothing in else condition then you need to change the field type of Number of days breached, from formula to number and update this field using process builder or trigger.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Abhishek Singh 88Abhishek Singh 88
Hi Khan Anas,
I tried this formula but it makes it null when stautus is not approved .
Khan AnasKhan Anas (Salesforce Developers) 
Yes, I have put null for the false condition. In the formula field, you cannot refer to the field's previous value. If you want to do nothing in else condition then you need to change the field type of Number of days breached, from formula to number and update this field using process builder or trigger.

Regards,
Khan Anas
This was selected as the best answer
Abhishek Singh 88Abhishek Singh 88
Ok, Got it . I updated using WF . Is it fine?
Khan AnasKhan Anas (Salesforce Developers) 
Yes Abhishek, that will work!