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
test777test777 

calculating the days based on quarterly wise.

Hi all ,

      I have one object called Leaves.This object contains fields like fromdate(date),todate(date),employee(lookup of employee object.)First time create the record in leaves object successfully.In this no of days as formula field like as follows.Noofdays=todate-fromdate+1 and Noofavailableleaves  like as follows,Noofavailabledays=12-noofdays.It works fine.

 

first time,

      Fromdate:1/5/2012

     Todate:1/6/2012

No.of.days=2

No.of.availableleaves=12-2=10

employee=abc;    

                       It works fine.


 

Second time when i try to create record with same employee,Then  i want the values like this in formula fields.

 Fromdate:2/5/2012

     Todate:2/6/2012

No.of.days=2

No.of.available leaves=10-2=8Because in the previous record the same employee is created and this emaployee contains noofavailableleavs is 10.next time i want to display the value vaue based on the first created record

employee=abc; 

 

Problem:But in the second time also display  the No.of.available leaves as 10.How to fix this.i hope it would be clear. Any one can u please help me.

 

Thanks in advance.

 

 

 

apex_keenapex_keen

Instead of Formula field, why not write a small trigger to update No of available leaves Field? .Through trigger you can find the existing value of this field for given employee and can do required calculation on this value