• rockybalbo
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Can i  write a sheduled trigger in such way that if the contact are not updating their time sheet after 120mins they have to notifie  with mail
 

In my controller class.I'm using Clockin and Clock out methods.Once i have logged in to my portal..I can able to see clockIn and Logout button.If i click on clockIn....Then i can able to see...Clockout and Logout buttons on My Vfpage1.Both clockIn and Clockout times are stored in Attendance Object.
                       I have another button Newsheet...if i click on that Newsheet button it will take me to another VFpage2 where i have to enter the detail like this(Username/timetaken...)...Once i have filled those fields..If click on Save Button/Cancel Button on Vfpage2....it will refer me to Vfpage1
                       
           But here we have some validation in my Apex class.Before you click on Newsheet...You must and should click on ClockIn..Because it will capture the clockin Time and store in Attendance object and it will get the ObjectId..So that you can go the Next vfpage2 when you click on Newsheet...Once you have save the record in Vfpage2 you will be refered to Vfpage1...you can able to see the record on Vfpage1 which you have saved on Vfpage2.Once you click clock out...ObjectId will become Null...Again in order to get the objectId..you have to select ClockIn....



        Here comes my problem...i have Login with credential..i will be my Vfpage1...When click on ClockIn...I will get the ObejctID from Attendance object....But if misatkenly  i have closed my Vfpage1...Where i used to get ObjectId...After some time if login With credentials again...It showing me Objectid=Null......

At the Backend i'm using a Checkbox  field...because that field My clockIn and Clockout Buttons are working.




Please check this code for reference..


public class AccountCont {

     Public Boolean CIN{get;set;}
     Public Boolean COUT{get;set;}
     public integer ClockIN;
     public integer ClockOut;
     public ID ConID{get; set;}
     public String objID{get; set;}
    
     public Account acc{get;set;}
     public contact con{get;set;}
     DateTime todaydate=system.now();
      
     Public Attendance__c obj{get;set;}
     Public Attendance__c obj1{get;set;}
     Public List<Attendance__c> attendtime{get;set;}
     Public List<Effort_sheet__c> effortsheet{get;set;}
     public List<Effort_sheet__c> L1{get;set;}
     Public Time__c ts{get;set;}
     Public decimal Add{get;set;}
     Public decimal Initial{get;set;}
    
    public AccountCont() {
     
          todaydate=System.Now();
          obj =new Attendance__c();
          obj1=new Attendance__c();
          acc= new account();
          con= new contact();
          ConID= ApexPages.currentPage().getParameters().get('ID');
          objID=ApexPages.currentPage().getParameters().get('objid');
         // obj1ID=Apexpages.currentpage().getparameters().get('obj1ID');
     
          L1=new List<Effort_sheet__c>();
          effortsheet= new list<Effort_sheet__c>();
          attendtime= new list<Attendance__c>();
        
        
         
          try{
            
       
             acc=[select id,name from Account where name='360degreecloud' limit 1];
          
             con=[select name,id,UserName__c,CheckBox__c,Total__c,check2__c,Totalporduct__c,Email from contact where id=:ConID];
          
             effortsheet = [SELECT Date__c,Description__c,User_Name__c,Work_Status__c,Comments__c,Time_Taken__c,Status__c,CreatedDate,EmailReference__c,Effort_sheet__c.contact__r.Name from Effort_sheet__c  where Contact__c=:con.id and Date__c = LAST_N_DAYS:2  ORDER BY CreatedDate desc];
             attendtime=[SELECT ClockIN__c,ClockOut__c,Contact__c,ProductiveTime_min__c,Name From Attendance__c where Contact__c=:ConID and CreatedDate=LAST_N_DAYS:2 ORDER BY ClockIN__c desc];
                   
               
               if(con.CheckBox__c==False){
                   CIN=True;
                  COUT=False;
                 }
                   else{
                   CIN=false;
                   COUT=true;
                   }
             }
                catch(exception e){
                
                 system.debug(e);
                }
       
        Try{
        
       obj1=[select name ,Contact__c,ClockIN__c from Attendance__c where id=:objID];// and Contact__c=:ConID ];
        
         }
     
             catch(exception e){
             system.debug(e);
              }
       Try{
       
         L1 =[SELECT id,createdDate,contact__c from Effort_sheet__c  where contact__c=:ConID and createdDate>=:obj1.ClockIN__c  and createdDate<=:todaydate];
        }
         
             catch(exception e){
             system.debug(e);
             }
          
      }
      
     public void query(){
       Add=0;
       
       for(Effort_sheet__c e:[Select SumofTimeTaken__c from Effort_sheet__c where Contact__c=:ConID and CreatedDate = today])
      {
      
         Add=Add+e.SumofTimeTaken__c;
        
     }
     con.Total__c=Add;
     update con;
     
      
     }  
     
     Public void quue(){
     Initial=0;
     for(Attendance__c a:[Select ProductiveTime_min__c from Attendance__c where Contact__c=:ConID and CreatedDate = today])
     
     {
     If(a.ProductiveTime_min__c!=null){
     
     initial=initial+a.ProductiveTime_min__c;
     }
     }    
        con.Totalporduct__c=initial;
        update con;
         
         }
            
         
          Public PageReference ClockIN (){
           // initial=0;
            //Add=0;
            obj.ClockIN__c=System.now();
          obj.Contact__c=string.valueof(conid);
          insert obj;
          con.CheckBox__c=True;
           update con;
        
             pageReference page = new PageReference('/apex/EffortsheetHomePage?Id='+ConID+'&objid='+obj.ID);
                page.setRedirect(true);
                 return page;
          }

         Public PageReference ClockOut(){
        
           obj1=[select name ,Contact__c,ClockIN__c,ClockOut__c from Attendance__c where id=:objID];// and Contact__c=:ConID];   
                   
           if(L1.size()>=1){      
            obj1.ClockOut__c=System.now();
             
             update obj1;
          
             con.CheckBox__c=False;
             update con;
             query();
             quue();
             
             pageReference page = new PageReference('/apex/EffortsheetHomePage?Id='+ConID+'&objid='+obj.ID);
                page.setRedirect(true);
                return page;
        }
 
          else{
          
           ApexPages.Message msg = new ApexPages.Message(Apexpages.Severity.ERROR, 'You unable to clock out without entering the atleast one record' );
           ApexPages.addMessage(msg);  
            return null;
               }
         
            
       }


       Public PageReference Newpage(){  //For creating new time sheet
       
         if(con.CheckBox__c==True){//This condition for validation the Newpage with out entering the clock In
        
        PageReference page = new PageReference('/apex/Effortsheets?ConId='+ConID+'&objid='+objID);
                page.setRedirect(true);
                return page;
                 
                }
        else{        
                 ApexPages.Message msg = new ApexPages.Message(Apexpages.Severity.ERROR, 'Please select CLOCKIN before you create Newsheet');
                 ApexPages.addMessage(msg);  
                
                return null;
        }
       }
        Public PageReference logout(){
        
      if(con.CheckBox__c==False){
                   
           con.check2__c=True;
             update con;       
        query();
          quue();
         ts = new Time__c();
         ts.contact__c=ConID;
         ts.TotalProductivetime__c=initial;
         ts.Total_tim__c=Add;
          insert ts;
           
         
        
        
         PageReference page = new PageReference('/apex/authentic');
                page.setRedirect(true);
                return page;
         }       
          else{
          
                  ApexPages.Message msg = new ApexPages.Message(Apexpages.Severity.ERROR, 'You are unable to Logout with out Clockout');
                 ApexPages.addMessage(msg);  
                
                return null;
          
          
          }
          
          
    }
    }

          

Hi


I'm setup salesforce Live chat..


I'm having problem in live chat button visible.The code added to footer & the chat button is added I have pasted the code.


The button is added on the side bar at the top. I have removed the old chat button code added to the content in that page. But the chat button is not visible.

 

Please help me..