You need to sign in to do that
Don't have an account?

formula for remaining days while entering new record
I have two fields in an object, Total_Casual_Leaves__c (Formula) 15 is constant value for it. Days_Requested__c (Number) that is user input. Now i want to write a formula for Remaining_leaves__c after Days_Requested__c taken. for that i am trying to write something like this
IF(
OR(
ISPICKVAL( Type_of_Leave__c , "Casual Leave"),
ISPICKVAL(Type_of_Leave__c, "Sick Leave")
),
Total_Casual_Leaves__c - Days_Requested__c ,
Total_Sick_Leaves__c - Days_Requested__c
)
Its working fine for one instance but if i create a new record then its taking 15 records as total leaves . If i enter a new record then it must calculate using Remaining_leaves__c. Could any one help me out
IF(
OR(
ISPICKVAL( Type_of_Leave__c , "Casual Leave"),
ISPICKVAL(Type_of_Leave__c, "Sick Leave")
),
Total_Casual_Leaves__c - Days_Requested__c ,
Total_Sick_Leaves__c - Days_Requested__c
)
Its working fine for one instance but if i create a new record then its taking 15 records as total leaves . If i enter a new record then it must calculate using Remaining_leaves__c. Could any one help me out
Formula fields are record-independent. They cannot see dat from other records. The best way to achieve this is to have another parent object (Something like Leave Applicant) as a parent in a master-detail relationship and have your Leave object as its child. This way, you can have rollup summary fields on the Leave Applicant object which count and display the number of Casual Leaves and remaining days for leaves created under it. Then, on the leave object records, you can create formula fields to show/calculate remaining days based on the values in the parent Leave Applicant record.
For help on rollup summary fields, please see: https://help.salesforce.com/HTViewHelpDoc?id=fields_about_roll_up_summary_fields.htm&language=en_US
If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.
Thanks,
Shashank