+ Start a Discussion
Mayuri NehulMayuri Nehul 

how to avoid changing formula field value before approval from approver in salesforce

Hi All,

I am new to Salesforce. I have given a task to build a Leave Management System application declaratively. I have created 2 formula fields Number of days leave taken and total leaves per year
I want to change the total leaves per year field value when approval approves it not before that. I have tried the below formula but I am getting the below error.
Can anyone please help me to resolve it.

For e.g: Employee applied for 2 days leave excluding weekends then the Number of days leave taken field is updated to 2 and the total leaves per year field will update 26-2=24 but I don't want to change the total leaves per year field to change before approval.
I want it 26 as it is. After approval from the approver, it should change to 24. Please help me to resolve this issue

The formula which I have tried is given below:

IF(ISPICKVAL( Status__c ='Approved'), 26-  no_days__c ,  totalLeavesPerYr__c )

Error:Formula cannot use another formula field that directly or indirectly refers to itself. Leave_Request__c.totalLeavesPerYr__c -> Leave_Request__c.totalLeavesPerYr__c

Thanks in advance
ShirishaShirisha (Salesforce Developers) 
Hi Mayuri,


As per the error message,you can't use the formula field which refers itself.So,you might need to write the trigger to restrict the change by storing the formula field value in one variable.

Please refer the below thread for more information.


Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

Mayuri NehulMayuri Nehul
Hi Shirisha,

Thanks for your reply,
I got your point but actually, my task is to achieve it using the declarative part. Can you please help me with this.

Thanks in advance