• Sandeep M 1
  • NEWBIE
  • 35 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 21
    Replies
I am trying to count the number of contacts associated with the account.Code is saved , but  not works.Please help me.

Trigger counting on contact(after update,after insert){
List<account> accids=New list<Account>();
For(contact con:trigger.new){
Accids.add(con.account);
}
For(contact con:trigger.new)
{
Account Acc;
Acc.count__c=accids.size();
}
}
I am using apex:inputText that holds a string with number(Integer) at controller side. Is there any way to display it as Number with commas (in USD Currency format)after typing input.
I implemented a delieveryapp using flexipages . I have a scenario like this , Lets say i have two objects Obj1,Obj2 where Obj1 is parent for Obj2. I am displaying Obj2 page in quickActionListItems .I want to prepopulate obj2 field values based on obj1 field values . How can i achieve this ?
How to bind the datepicker value to controller. I used onfocus="DatePicker.pickDate" but it was not displaying datepicker in sandbox so i am using as below. 


<apex:page standardController="SFDC_Employee__c" extensions="payslipext" sidebar="true" showheader="true">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!SFDC_Employee__c.Month__c}"/>

</apex:pageBlockSection>
<apex:outputLink value="PaySlipPage" id="page">Generate
<apex:param value="{!dateName}" /></apex:outputlink>
</apex:pageBlock>
</apex:form>

</apex:page>

could any one tell me how to bind inputField value="{!SFDC_Employee__c.Month__c} in controller when Outputlink 'Generate' is clicked
I am trying to create a summary report in which I am trying to create percentage formula.I used the formula for calculating for percentage as Operational_Metrics__c.Primary_Segregated_Organic_Waste__c:SUM/Operational_Metrics__c.Total_Waste__c:SUM
But, I observed that it displayed percentage successfully as a separate column which is not my requirement. 

User-added image
My requirement is I want to display Percentage as below the total it should display 100% under sum of  waste total and 8.23% as percentage of primary organic waste under sum of primary organic waste total
have two objects SFDC_PTO_Request__c (child),Employee__c (parent) with Master-Detail relationship. I need to display parent on child record while inserting on visualforce page which was a lookup relationship. I am trying as below

<apex:page standardController="SFDC_PTO_Request__c" recordSetVar="SFDC_PTO_Request" sidebar="false">
<apex:form >
<apex:pageBlock title="Leave Request Edit">
<apex:pageBlockButtons >
     <apex:commandButton action="{!Save}" value="Save"/>
     <apex:commandButton action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information" columns="2" collapsible="false">
      <apex:inputField value="{!SFDC_PTO_Request__c.Type_of_leave__c}"/>
      <apex:inputField value="{!SFDC_PTO_Request__c.Available_Casual_Leaves__c}"/>    
      <apex:inputField value="{!SFDC_PTO_Request__c.Available_Sick_Leaves__c}"/>  
      <apex:inputField value="{!SFDC_PTO_Request__c.Request_Type__c}"/>  
      <apex:inputField value="{!SFDC_PTO_Request__c.Employee__c}"/>
</apex:pageBlockSection>
  <apex:pageBlockSection title="Request Dates" columns="2" collapsible="false">
      <apex:inputField value="{!SFDC_PTO_Request__c.Request_Start_Date__c}"/>
      <apex:inputField value="{!SFDC_PTO_Request__c.Request_End_Date__c}"/> 
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

User-added image

could some one help me to display the lookup field of parent on child record
I have a trigger which has test coverage upto 39% but while deploying it is giving error as my trigger coverage is only 0% . could anybody help me out.

below is my error.

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
Stack Trace: Class.TestTrigger.validateTrigger: line 7, column 1

my trigger is

trigger employeedaysoffTrigger on SFDC_PTO_Request__c (after update,after insert) {
    Set<ID> Ids=new Set<Id>();
    Set<ID> bIds=new Set<Id>();
    Decimal d,e,f;
    List<SFDC_Employee__c> emp= new LIST<SFDC_Employee__c>();
    List<SFDC_PTO_Request__c> bbq=new LIST<SFDC_PTO_Request__c>();
    List<SFDC_PTO_Request__c> lq=new LIST<SFDC_PTO_Request__c>();
    //To avoid recursion using static boolean variable
    private static boolean run = true;
   if(TriggerContextUtility.isFirstRun())
    {
         run=false;
    //Take the ids of all newly inserting or updating records
    for(SFDC_PTO_Request__c b:Trigger.New)
    {
        if(b.Employee__c!=null)
        {
          Ids.add(b.Employee__c);
          bIds.add(b.Id);
        }
    }
 
    //list out all values from leave request
    lq= [SELECT id,employee__r.id,employee__r.total_casual_days_off__c,employee__r.total_sick_days_off__c,
         total_casual_leaves__c,total_sick_leaves__c,available_casual_leaves__c,available_sick_leaves__c,
         status__c,type_of_leave__c from SFDC_PTO_Request__c where id =:bIds];
    //Check the status of the leave request after record is approved/rejected
    if(lq[0].status__c == 'Approved')
    {
     
    for(AggregateResult ar:[select Employee__c em,sum(days_off__c) s,sum(casual_days_off__c) c,
                           sum(sick_days_off__c) dos from SFDC_PTO_Request__c
                           where Employee__c in : Ids Group BY Employee__c])
    {
   
        d= (Decimal) ar.get('s');
        e= (Decimal) ar.get('c');
        f= (Decimal) ar.get('dos');
    }
    //Update fields of total casual days off and total sick days off in employee object
    for(SFDC_Employee__c bac:[select id,total_days_off__c,total_casual_days_off__c,total_sick_days_off__c
                         from SFDC_Employee__c where id=:Ids])
    {
       if(lq[0].type_of_leave__c=='Casual Leave')
       {
           bac.total_casual_days_off__c=e;
           emp.add(bac);
         
       }
       else if(lq[0].type_of_leave__c=='Sick Leave')
       {
           bac.total_sick_days_off__c=f;
           emp.add(bac);
       }
    }
    //update available casual and sick leaves fields in leave request object
    for(SFDC_PTO_Request__c l: lq)
    {   
            if(l.type_of_leave__C=='Casual Leave')
            {  
                l.Available_Sick_Leaves__c=l.Total_Sick_Leaves__c-f;
                l.available_casual_leaves__c=l.total_casual_leaves__c-e;
              
                bbq.add(l);
            }
            else if(l.type_of_leave__c=='sick leave')
            {
                l.available_sick_leaves__c=l.total_sick_leaves__c-f;
                l.available_casual_leaves__c=l.total_casual_leaves__c-e;
                bbq.add(l);
            }
    }
    TriggerContextUtility.setFirstRunFalse();
    update bbq;
    update emp;
    }
    }
}

my test class for the above trigger is

@isTest
public class TestTrigger
{
    static testmethod void validateTrigger()
    {
         SFDC_PTO_Request__c spreq= new SFDC_PTO_Request__c(Employee__c='a0EK00000092v59',available_casual_leaves__c=20,available_sick_leaves__c=10);
         insert spreq;      
         spreq=[select id,Employee__c,available_casual_leaves__c,Available_sick_Leaves__c,status__c,type_of_leave__c from SFDC_PTO_Request__c where Employee__c='a0EK00000092v59'];
         System.assertEquals(20,spreq.Available_Casual_Leaves__c);
         System.assertEquals(10,spreq.Available_sick_Leaves__c);
         SFDC_Employee__c emp=new SFDC_Employee__c();
         emp.Total_casual_days_off__c=20;
         emp.Total_sick_days_off__c=10;
         emp.Pan_Number__c='bmplm8889m';
         insert emp;
         emp=[select id,total_days_off__c,total_casual_days_off__c,total_sick_days_off__c
                        from SFDC_Employee__c where id='a0EK00000092v59'];
         System.assertEquals(20,emp.Total_casual_days_off__c);
         System.assertEquals(10,emp.Total_sick_days_off__c);
       
    }
}
I have a trigger which has test coverage upto 39% but while deploying it is giving error as my trigger coverage is only 0% . could anybody help me out.

my trigger is 

trigger employeedaysoffTrigger on SFDC_PTO_Request__c (after update,after insert) {
    Set<ID> Ids=new Set<Id>();
    Set<ID> bIds=new Set<Id>();
    Decimal d,e,f;
    List<SFDC_Employee__c> emp= new LIST<SFDC_Employee__c>();
    List<SFDC_PTO_Request__c> bbq=new LIST<SFDC_PTO_Request__c>();
    List<SFDC_PTO_Request__c> lq=new LIST<SFDC_PTO_Request__c>();
    //To avoid recursion using static boolean variable
    private static boolean run = true;
   if(TriggerContextUtility.isFirstRun())
    {
         run=false;
    //Take the ids of all newly inserting or updating records
    for(SFDC_PTO_Request__c b:Trigger.New)
    {
        if(b.Employee__c!=null)
        {
          Ids.add(b.Employee__c);
          bIds.add(b.Id);
        }
    }
  
    //list out all values from leave request
    lq= [SELECT id,employee__r.id,employee__r.total_casual_days_off__c,employee__r.total_sick_days_off__c,
         total_casual_leaves__c,total_sick_leaves__c,available_casual_leaves__c,available_sick_leaves__c,
         status__c,type_of_leave__c from SFDC_PTO_Request__c where id =:bIds];
    //Check the status of the leave request after record is approved/rejected
    if(lq[0].status__c == 'Approved')
    {
      
    for(AggregateResult ar:[select Employee__c em,sum(days_off__c) s,sum(casual_days_off__c) c,
                           sum(sick_days_off__c) dos from SFDC_PTO_Request__c
                           where Employee__c in : Ids Group BY Employee__c])
    {
    
        d= (Decimal) ar.get('s');
        e= (Decimal) ar.get('c');
        f= (Decimal) ar.get('dos');
    }
    //Update fields of total casual days off and total sick days off in employee object
    for(SFDC_Employee__c bac:[select id,total_days_off__c,total_casual_days_off__c,total_sick_days_off__c
                         from SFDC_Employee__c where id=:Ids])
    {
       if(lq[0].type_of_leave__c=='Casual Leave')
       {
           bac.total_casual_days_off__c=e;
           emp.add(bac);
          
       }
       else if(lq[0].type_of_leave__c=='Sick Leave')
       {
           bac.total_sick_days_off__c=f;
           emp.add(bac);
       }
    }
    //update available casual and sick leaves fields in leave request object
    for(SFDC_PTO_Request__c l: lq)
    {    
            if(l.type_of_leave__C=='Casual Leave')
            {   
                l.Available_Sick_Leaves__c=l.Total_Sick_Leaves__c-f;
                l.available_casual_leaves__c=l.total_casual_leaves__c-e;
               
                bbq.add(l);
            }
            else if(l.type_of_leave__c=='sick leave')
            {
                l.available_sick_leaves__c=l.total_sick_leaves__c-f;
                l.available_casual_leaves__c=l.total_casual_leaves__c-e;
                bbq.add(l);
            }
    }
    TriggerContextUtility.setFirstRunFalse();
    update bbq;
    update emp;
    }
    }
}

my test class for the above trigger is

@isTest
public class TestTrigger
{
    static testmethod void validateTrigger()
    {
         SFDC_PTO_Request__c spreq= new SFDC_PTO_Request__c(Employee__c='a0EK00000092v59',available_casual_leaves__c=20,available_sick_leaves__c=10);
         insert spreq;       
         spreq=[select id,Employee__c,available_casual_leaves__c,Available_sick_Leaves__c,status__c,type_of_leave__c from SFDC_PTO_Request__c where Employee__c='a0EK00000092v59'];
         System.assertEquals(20,spreq.Available_Casual_Leaves__c);
         System.assertEquals(10,spreq.Available_sick_Leaves__c);
         SFDC_Employee__c emp=new SFDC_Employee__c();
         emp.Total_casual_days_off__c=20;
         emp.Total_sick_days_off__c=10;
         emp.Pan_Number__c='bmplm8889m';
         insert emp;
         emp=[select id,total_days_off__c,total_casual_days_off__c,total_sick_days_off__c
                        from SFDC_Employee__c where id='a0EK00000092v59'];
         System.assertEquals(20,emp.Total_casual_days_off__c);
         System.assertEquals(10,emp.Total_sick_days_off__c);
        
    }
}
I am writing a trigger to copy childs field value into parent field value. Let say operational_metrics__c is a parent object and contacts is its child object with lookup relation ship. Contact object has fields like lastname,driver_name__c,vehicle_type__C and operational_metrics__c has driver_name__c field. I need to copy driver_name__c in contact to driver_name__c in operational_metrics__c. I am trying like this

trigger opMetricsTrigger on Operational_Metrics__c (after insert,after update)
{
    Operational_Metrics__c[] op=null;
    Set<string> opIds = new Set<string>();
    Date d1,d2,cDate,pMont,cRegDate;  
    String dat;
    Contact con;
    decimal avg,nDays;
    Decimal tw;
    String convertedDate;
    String mTest,actionTaken,oAction;
    List<Operational_Metrics__c> c= new LIST<Operational_Metrics__c>();
    List<Operational_Metrics__c> cUpdate= new LIST<Operational_Metrics__c>();
    List<Operational_Metrics__c> cU= new LIST<Operational_Metrics__c>();
    private static boolean run = true;
    if(TriggerContextUtility.isFirstRun())
    {
     run=false;
     for (Operational_Metrics__c e : Trigger.new)
     {
         if(e.u_id__c != null)
         opIds.add(e.u_id__c );
     }
      
     List<Operational_Metrics__c> opm = [select Unique_Pile_ID__c,Surveyor__c,driver_name__C,u_id__C,Uid_number__c, Composting_Method__c,Pile_Monitoring_Date__c,Average_Temperature__c,Moisture_Test__c,Pile_Monitoring_Action_Taken__c,Other_Action__c,Pile_Input_Register_Date__c,Total_Waste_Input_on_the_Pile__c,Pile_Completion_Stage__c,Date_Pile_COmpleted__c,Curing_Batch_Register_Date__c,No_of_Days__c,No_of_Days_for_piling__c  from operational_metrics__c where u_id__c in :opIds];
     List<Operational_Metrics__c> uOpm = [select Unique_Pile_ID__c,Surveyor__c,u_id__C,Uid_number__c, Composting_Method__c,Pile_Monitoring_Date__c,Average_Temperature__c,Moisture_Test__c,Pile_Monitoring_Action_Taken__c,Other_Action__c,Pile_Input_Register_Date__c,Total_Waste_Input_on_the_Pile__c,Pile_Completion_Stage__c,Date_Pile_COmpleted__c,Curing_Batch_Register_Date__c,No_of_Days__c,No_of_Days_for_piling__c  from operational_metrics__c where u_id__c in :opIds and Pile_Completion_Stage__c='yes'];   
     
     List<Operational_Metrics__c> dName=[select Project__c,driver_name__c,Surveyor__c,vehicle_type__c,vehicle_number__c, (SELECT contact.LastName FROM Contacts__r)  from operational_metrics__c];
     for(Operational_Metrics__c d : dName)
     {
         if(d.Project__c=='Nalgonda')
         {
             for(contact cont:d.contacts__r)
             {
                 if(d.Vehicle_Type__c=='Tractor')
                 {
                      d.Driver_Name__c=cont.lastname;
                        // c.add(d);
                 }
             }
         }
         else if(d.Project__c=='Miryalaguda')
         {
             System.debug('prj2 '+d);
         }
     }
     for(Operational_Metrics__c ops : opm)
     {
  if(ops.Surveyor__c=='NLDA Supervisor')
        {
            ops.Project__c='Nalgonda';
        }
         else if(ops.Surveyor__c=='Araveli Nagaswara')
         {
             ops.project__C = 'Miryalaguda';
         }
        if(ops.Pile_Completion_Stage__c=='yes')
         {
           
             d1=ops.Date_Pile_COmpleted__c;
             convertedDate=String.valueOf(d1.day())+String.valueOf(d1.month());
             tw=ops.Total_Waste_Input_on_the_Pile__c;
             cDate=ops.Date_Pile_COmpleted__c;
         } 
         else if(ops.Curing_Batch_Register_Date__c!=null)
         {
             d2=ops.Curing_Batch_Register_Date__c;
             System.debug('records2 are '+ops);
         }
         else
         {
             avg=ops.Average_Temperature__c;
             mTest=ops.Moisture_Test__c;
             actionTaken=ops.Pile_Monitoring_Action_Taken__c;
             oAction=ops.Other_Action__c;
             pMont=ops.Pile_Monitoring_Date__c;
             cRegDate=ops.Curing_Batch_Register_Date__c;
         
          }
        if(d1!=null && d2!=null)
        {
           ops.No_of_Days_for_piling__c=d1.daysBetween(d2);
            nDays=ops.No_of_Days_for_piling__c;
           
            c.add(ops);
        }
     
     }
      for(Operational_Metrics__c u:uOpm)
      {
          u.Total_Waste_Input_on_the_Pile__c=tw;
          u.Average_Temperature__c=avg;
          u.Moisture_Test__c=mTest;
          u.Pile_Monitoring_Action_Taken__c=actionTaken;
          u.Other_Action__c=oAction;
          u.Pile_Monitoring_Date__c=pMont;
          u.Curing_Batch_Register_Date__c=cRegDate;
          u.No_of_Days_for_piling__c=nDays;
          u.Curing_Batch_Register_Date__c=d2;
       
          cUpdate.add(u);
      }
    
      TriggerContextUtility.setFirstRunFalse();
       update c;
       update cUpdate;
    }
}

But the child record value is not updating into parents record. could anyone help me out
I want to update record after insert and after update , i am writing trigger 

trigger opMetricsTrigger on Operational_Metrics__c (after insert,after update)
{
     Operational_Metrics__c[] op=null;
     Set<string> opIds = new Set<string>();
     Date d1,d2;
       List<Operational_Metrics__c> c= new LIST<Operational_Metrics__c>();
     private static boolean run = true;
     if(run)
     {
       run=false;
     for (Operational_Metrics__c e : Trigger.new)
     {
         if(e.u_id__c != null)
         opIds.add(e.u_id__c );
     }
      
     List<Operational_Metrics__c> opm = [select Unique_Pile_ID__c,u_id__C, Project__c,Composting_Method__c,Pile_Monitoring_Date__c,Average_Temperature__c,Moisture_Test__c,Pile_Monitoring_Action_Taken__c,Other_Action__c,Pile_Input_Register_Date__c,Total_Waste_Input_on_the_Pile__c,Pile_Completion_Stage__c,Date_Pile_COmpleted__c,Curing_Batch_Register_Date__c,No_of_Days__c  from operational_metrics__c where u_id__c in :opIds];
     for(Operational_Metrics__c ops : opm)
     {
        if(ops.Pile_Completion_Stage__c=='yes')
         {
             System.debug('records1 are '+ops.Date_Pile_COmpleted__c);
             d1=ops.Date_Pile_COmpleted__c;
         } 
         else if(ops.Curing_Batch_Register_Date__c!=null)
         {
             d2=ops.Curing_Batch_Register_Date__c;
             System.debug('records2 are '+ops.Curing_Batch_Register_Date__c);
    
         }
        if(d1!=null && d2!=null)
        {
           
            ops.No_of_Days_for_piling__c=d1.daysBetween(d2);
             System.debug('no of days '+ops.No_of_Days_for_piling__c);
            c.add(ops);
        }
       
     }
    

       update c;
    }
}

I am able to get all debug logs correctly but when i am updating the record it is throwing CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY error which causes recursive calls to the trigger. could any one help me out.
I want to update the field in multiple records based on the unique_pile_id__c that is unique for all the multiple records. I am trying to write trigger like this

trigger opMetricsTrigger on Operational_Metrics__c (before insert,before update)
{
Operational_Metrics__c[] op=null;
Set<Id> opIds = new Set<Id>();
public static boolean run = true;
if(run)
{

   run=false;
for (Operational_Metrics__c e : Trigger.new)
{
     if(e.Unique_Pile_ID__c != null)
     opIds.add(e.Unique_Pile_ID__c );
}

  Map<Id, Operational_Metrics__c> y = new Map<Id, Operational_Metrics__c>([select Unique_Pile_ID__c,unique_id__C, Project__c,Composting_Method__c,Pile_Monitoring_Date__c,Average_Temperature__c,Moisture_Test__c,Pile_Monitoring_Action_Taken__c,Other_Action__c,Pile_Input_Register_Date__c,Total_Waste_Input_on_the_Pile__c,Pile_Completion_Stage__c,Date_Pile_COmpleted__c,Curing_Batch_Register_Date__c,No_of_Days__c  from operational_metrics__c where Unique_Pile_ID__c in :opIds]);
for (Operational_Metrics__c oc : [select Unique_Pile_ID__c,unique_id__C, Project__c,Composting_Method__c,Pile_Monitoring_Date__c,Average_Temperature__c,Moisture_Test__c,Pile_Monitoring_Action_Taken__c,Other_Action__c,Pile_Input_Register_Date__c,Total_Waste_Input_on_the_Pile__c,Pile_Completion_Stage__c,Date_Pile_COmpleted__c,Curing_Batch_Register_Date__c,No_of_Days__c  from operational_metrics__c where Unique_Pile_ID__c in :opIds])
{
      System.debug('oc '+y.get(oc.Unique_Pile_ID__c));
}


}
}

but when i am saving a records it is throwing execution of BeforeUpdate caused by: System.StringException: Invalid id: 10-Ber1: External entry point here 10-Ber1 is the unique_pile_id__c could any one help me out
I have a controller without any dml statements. How can i write test class for the controller to improve the coverage area ?
public with sharing class payslipController

public Decimal loandeduction { get; set; }
public Decimal oIncome { get; set; }
public Decimal Asleaves { get; set; }
public Decimal tsleaves { get; set; }
public Decimal Acleaves { get; set; }
public Decimal tcleaves { get; set; }
public Decimal tds { get; set; }
public Decimal tnetsalary { get; set; }
public Decimal tdeduce { get; set; }
public Decimal pt { get; set; }
public Decimal pf { get; set; }
public Decimal tsalaryAmount { get; set; }
public Decimal obAmount { get; set; }
public Decimal caAmount { get; set; }
public Decimal hraAmount { get; set; }
public Decimal deductions { get; set; }
public Decimal bSalary { get; set; }
public Decimal lwp { get; set; }
public Decimal holidays { get; set; }
public Decimal workingDays { get; set; }
public Integer no_days { get; set; }
public String email { get; set; }
public String gender { get; set; }
public String designation { get; set; }
public String doj { get; set; }
public String panNumber { get; set; }
public String AccountNumber { get; set; }
public String empNo { get; set; }
public String empName { get; set; }
public String month{ get; set; }
public String org_website { get; set; }
public String org_email { get; set; }
public String org_Address { get; set; }
public String org_Name { get; set; }
//Getter and Setters for Objects
public Organization__c orgs{get;set;}
public SFDC_Employee__c employee{get;set;}
public Employee_Monthly_Info__c eMonthInfo{get;set;}
public string empNumbertoget{get;set;}
//Constructor for the controller
public payslipController()
{
    empNumbertoget= ApexPages.CurrentPage().getParameters().get('eno');
    Date selectedDate =  Date.today();
    Date firstDate = selectedDate.toStartOfMonth();
    Date lastDate = firstDate.addDays(date.daysInMonth(selectedDate.year() , selectedDate.month())  - 1);
    DateTime d = datetime.now();
    month= d.format('MMMMM/yyyy');
    String monthName= d.format('MMMMM');


    List<AggregateResult> sumLrequest=[Select sum(days_off__c) s,Request_Start_Date__c, Request_End_Date__c  from SFDC_PTO_Request__c where   Request_Start_Date__c> :firstDate  and Request_End_Date__c< : lastdate and employee__r.Employee_ID__c=:empNumberToGet group by Request_End_Date__c,Request_Start_Date__c ];


    //Retrieve all the required data from Organization__c,Employee__c,Bank_Account__c,Employee_Monthly_Info__c (custom objects) Using SOQL
    List<Organization__c> org=[select id,name,address__c,Email__c,website__c from Organization__c where name='Waste Ventures India Private Limited'];

    List<SFDC_Employee__c> emp=[select name,Employee_ID__c,Title__c,Pan_Number__c,Start_Date__c,Email_Address__c,Gender__c,Bank_Account_No__c,Bank_Name__c,available_casual_leaves__C,available_sick_leaves__c  FROM SFDC_Employee__c where Employee_ID__c=:empNumbertoget];

    List<Employee_Monthly_Info__c> eInfo=[select Employee_Monthly_Info__c.employee__R.name,Medical_Allowance__c,Total_Salary_Amount__c,Net_Salary__c,Total_Deduction__c,Other_Income__c,Loan_Deduction__c,HRA_AMount__c,pt__c,pf__c,Conveyance_Allowance_Amount__c,TDS__c,paid_holidays__c,Total_Casual_Leaves__c,Total_Sick_Leaves__c,basic_salary__c,Leave_with_Pay__c,working_days__c from Employee_Monthly_Info__c where Employee_Monthly_Info__c.employee__R.Employee_ID__c=:empNumbertoget];

    //Retrieve Organization related data

    if(org.size()==0)
    {
         System.debug('org is '+org);
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Organization details are empty'));
    }

    else
    {
    //Retrieve Organization related data
    orgs=org[0];
    org_Name=orgs.Name;
    org_Address = orgs.Address__c;
    org_email=orgs.email__c;
    org_website=orgs.website__c;

    //Retrieve Employee related data
    employee=emp[0];
    empName = employee.name;
    empNo=employee.Employee_ID__c;
    acleaves=employee.available_casual_leaves__c;
    asleaves=employee.available_sick_leaves__c;
    panNumber =employee.Pan_Number__c;
    Date dat=employee.Start_Date__c;
    doj=String.valueOf(dat);
    designation=employee.Title__c;
    gender=employee.gender__c;
    email=employee.Email_Address__c;
    AccountNumber = employee.Bank_Account_No__c;
    no_days=Date.daysInMonth(d.year(), d.month());

     if(sumLrequest.size() > 0)
    {
       String str = '' + sumLrequest[0].get('s') ;
       lwp= Decimal.ValueOf(str).setScale(0) ;

    }
    if(sumLrequest.size()==null)
    {
       String str = '' + 0;
       lwp= Decimal.ValueOf(str).setScale(0) ;
    }
    //Retrieve Employee monthly Related data
    eMonthInfo=eInfo[0];
   loandeduction =emonthInfo.loan_deduction__c;
    oIncome=eMonthInfo.other_income__c;
    workingDays =eMonthInfo.working_days__c;
   tcleaves=eMonthInfo.total_casual_leaves__c;
    tsleaves=eMonthInfo.total_Sick_leaves__c;
    bSalary=eMonthInfo.basic_salary__c;
    deductions=eMonthInfo.total_deduction__c;
    tsalaryAmount=eMonthInfo.Total_Salary_Amount__c;
    pf=eMonthInfo.pf__c;
    pt=eMonthInfo.pt__c;
    tdeduce=eMonthInfo.total_deduction__c;
    caAmount=eMonthInfo.Conveyance_Allowance_Amount__c;
    hraAmount=eMonthInfo.HRA_Amount__c;
    obAmount=eMonthInfo.Medical_Allowance__c;
    tnetsalary=eMonthInfo.net_salary__c;
    tds=eMonthInfo.tds__c;
    }

}
}
I have an Custom_Object_A__c which has a look up relation with Custom_Object_B__c. 
Custom_Object_A__c has a field NumberS__c (Number(15,0)).
Custom_Object_b__c has a field parentNumber__c((Number(15,0))
When i want to create a new record in Custom_Object_b__c then i need to autopopulate parentNumber__c field with NumberS__c  value. How can i achieve without using URL hack ?
i want to insert,update two custom fields in an object. i wrote trigger

trigger availableLeavesTrigger on Leave_Request__c (after insert,after UPDATE) {
List<id> lrs=new List<id>();
List<Leave_request__c> lea=new List<Leave_request__c>();
for(Leave_Request__c leave:Trigger.New)
{
  lrs.add(leave.id);
}
List<Leave_request__c> lc=[select id,name,available_casual_leaves__c,available_sick_leaves__c,days_off__c,type_of_leave__C from leave_request__c where id =:lrs ];
for(Leave_Request__c leave:lc)
{
    if(leave.type_of_leave__C=='casual leave')
    {
        leave.available_casual_leaves__c=leave.available_casual_leaves__c-leave.days_off__c;   
        lea.add(leave);  
    }
    else if(leave.type_of_leave__c=='sick leave')
    {
        leave.available_sick_leaves__c=leave.available_sick_leaves__c-leave.days_off__c;
        lea.add(leave);
    }
}
update lea;
}

I just cant able to insert or update the values into the fields. could anyone help me out
Hi, 

I had three custom fields like available_casual_leaves__c,available_sick_leaves__c and days_off __c on leave_request__c object.
the default values of available_Casual_leaves__c is 20 and available_sick_leaves__c is 10. Now i have to update the default values in both available_casual_leaves__c and available_sick_leaves__c. for that i am writing

trigger availableLeavesTrigger on Leave_Request__c (before Update) {
    List<Leave_Request__c> lr= new List<Leave_Request__c>();
    List< Leave_Request__c> IdsForUpdate = new List< Leave_Request__c>();
    Leave_Request__c lqr=new Leave_Request__c();
    List<leave_request__c> leaveList=new LIST<leave_request__c>();   
    if(trigger.isUpdate)
    {
        for(Leave_Request__c l:trigger.new)
        {
            IdsForUpdate.add(l);
        }       
    }
    for(leave_request__C leave:[Select id,name, type_of_leave__c,Available_casual_leaves__c,
        Available_sick_leaves__c,  days_off__c from Leave_Request__c where id=:IdsForUpdate])
    {
       System.debug('isjfh 0 -- > '+leave);
        if(leave.type_of_leave__C=='casual leave')
        {
            System.debug('0 -- > '+leave);
            leave.available_casual_leaves__c=leave.available_casual_leaves__c-leave.days_off__c;
            System.debug('1 -- > '+leave.available_casual_leaves__c);
            leaveList.add(leave);          
        }
        else if(leave.type_of_leave__c=='sick leave')
        {
            leave.available_sick_leaves__c=leave.available_sick_leaves__c-leave.days_off__c;
            System.debug('2 -- > '+leave.available_sick_leaves__c);
            leaveList.add(leave);
        }
      }
      update leavelist;
  }

but i am not able to see any debug logs and ofcourse the values are not updating could any one tell me where i am going wroing
i have three custom objects.

Bank_Account__c(Parent) --->Bank_transaction__c(child)

Bank_Account__c(Parent) --->Bank_statement__c(child)

Bank_transaction__c fields are date__c, credit__c, debit__c

Bank_statement__c fields are start_date__c, end_date__c

I just want to write a single query to get the records of Bank_transaction__c which date__c is in between start_date__c and end_date__c of bank_statement__c object. How can i achieve this
I want to write a soql query , My scenario is as follows. I have three objects objectA,objectB,objectC. objectA is the parent object for both objectB,objectC.

objectA - objectB (Master-detail relationship)
objectA - objectC (Master-detail relationship)

Now i want to retrieve records from objectC to objectB along with objectA fields. How can i achieve such functionality . any examples would help me out.
On the beginning of this month , I scheduled my Dev 401 exam. While i am writing ,In middle of the exam , the exam has been ended saying some error as out of webcam even i am infront of it as per the conditions. I immediatly opened a case and waiting for their reply . And couple of days back i opened another case mentioning the same , but still there is no response. I have my case number. How can i check my case status ? Why does this suspension is done ? what does it mean ? What can i do now ? could any one suggest me
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
Hello all,

I want to pass the List values of an object to the other Visualforce page using a query. Since we cannot pass list as parameter to other page i am using

public PageReference DisplayDetails() {
      
        PageReference reRend = new PageReference('/apex/wrapperCustomObjpage2');
        reRend.setRedirect(false);
        return reRend;
       
    }

But the variables in the controller were reintializing after entering into the other page. I am not able to display the data into pageblocktable. Could any one suggest me the best approach

Iam trying to count the number of contacts on account, Iam getting the following error message

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Account> at line 10 column 1    

Trigger counting on contact(after update,after insert){
Set<account> accids=New Set<Account>();
For(contact c:trigger.new){
Accids.add(c.Account);
}
List<Contact> con = [select id  from contact where AccountID IN:accids];
List<Account> Acc=[Select count__C from account where id IN:accids ];
For(contact c:trigger.new)
{
Acc.count__c=con.size();
}
}
Hi folks,
         Can anyone tell me what are the hottest topics in salesforce?
I need atleast 20 topic names.

 
I am trying to count the number of contacts associated with the account.Code is saved , but  not works.Please help me.

Trigger counting on contact(after update,after insert){
List<account> accids=New list<Account>();
For(contact con:trigger.new){
Accids.add(con.account);
}
For(contact con:trigger.new)
{
Account Acc;
Acc.count__c=accids.size();
}
}
have two objects SFDC_PTO_Request__c (child),Employee__c (parent) with Master-Detail relationship. I need to display parent on child record while inserting on visualforce page which was a lookup relationship. I am trying as below

<apex:page standardController="SFDC_PTO_Request__c" recordSetVar="SFDC_PTO_Request" sidebar="false">
<apex:form >
<apex:pageBlock title="Leave Request Edit">
<apex:pageBlockButtons >
     <apex:commandButton action="{!Save}" value="Save"/>
     <apex:commandButton action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information" columns="2" collapsible="false">
      <apex:inputField value="{!SFDC_PTO_Request__c.Type_of_leave__c}"/>
      <apex:inputField value="{!SFDC_PTO_Request__c.Available_Casual_Leaves__c}"/>    
      <apex:inputField value="{!SFDC_PTO_Request__c.Available_Sick_Leaves__c}"/>  
      <apex:inputField value="{!SFDC_PTO_Request__c.Request_Type__c}"/>  
      <apex:inputField value="{!SFDC_PTO_Request__c.Employee__c}"/>
</apex:pageBlockSection>
  <apex:pageBlockSection title="Request Dates" columns="2" collapsible="false">
      <apex:inputField value="{!SFDC_PTO_Request__c.Request_Start_Date__c}"/>
      <apex:inputField value="{!SFDC_PTO_Request__c.Request_End_Date__c}"/> 
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

User-added image

could some one help me to display the lookup field of parent on child record
I have a controller without any dml statements. How can i write test class for the controller to improve the coverage area ?
public with sharing class payslipController

public Decimal loandeduction { get; set; }
public Decimal oIncome { get; set; }
public Decimal Asleaves { get; set; }
public Decimal tsleaves { get; set; }
public Decimal Acleaves { get; set; }
public Decimal tcleaves { get; set; }
public Decimal tds { get; set; }
public Decimal tnetsalary { get; set; }
public Decimal tdeduce { get; set; }
public Decimal pt { get; set; }
public Decimal pf { get; set; }
public Decimal tsalaryAmount { get; set; }
public Decimal obAmount { get; set; }
public Decimal caAmount { get; set; }
public Decimal hraAmount { get; set; }
public Decimal deductions { get; set; }
public Decimal bSalary { get; set; }
public Decimal lwp { get; set; }
public Decimal holidays { get; set; }
public Decimal workingDays { get; set; }
public Integer no_days { get; set; }
public String email { get; set; }
public String gender { get; set; }
public String designation { get; set; }
public String doj { get; set; }
public String panNumber { get; set; }
public String AccountNumber { get; set; }
public String empNo { get; set; }
public String empName { get; set; }
public String month{ get; set; }
public String org_website { get; set; }
public String org_email { get; set; }
public String org_Address { get; set; }
public String org_Name { get; set; }
//Getter and Setters for Objects
public Organization__c orgs{get;set;}
public SFDC_Employee__c employee{get;set;}
public Employee_Monthly_Info__c eMonthInfo{get;set;}
public string empNumbertoget{get;set;}
//Constructor for the controller
public payslipController()
{
    empNumbertoget= ApexPages.CurrentPage().getParameters().get('eno');
    Date selectedDate =  Date.today();
    Date firstDate = selectedDate.toStartOfMonth();
    Date lastDate = firstDate.addDays(date.daysInMonth(selectedDate.year() , selectedDate.month())  - 1);
    DateTime d = datetime.now();
    month= d.format('MMMMM/yyyy');
    String monthName= d.format('MMMMM');


    List<AggregateResult> sumLrequest=[Select sum(days_off__c) s,Request_Start_Date__c, Request_End_Date__c  from SFDC_PTO_Request__c where   Request_Start_Date__c> :firstDate  and Request_End_Date__c< : lastdate and employee__r.Employee_ID__c=:empNumberToGet group by Request_End_Date__c,Request_Start_Date__c ];


    //Retrieve all the required data from Organization__c,Employee__c,Bank_Account__c,Employee_Monthly_Info__c (custom objects) Using SOQL
    List<Organization__c> org=[select id,name,address__c,Email__c,website__c from Organization__c where name='Waste Ventures India Private Limited'];

    List<SFDC_Employee__c> emp=[select name,Employee_ID__c,Title__c,Pan_Number__c,Start_Date__c,Email_Address__c,Gender__c,Bank_Account_No__c,Bank_Name__c,available_casual_leaves__C,available_sick_leaves__c  FROM SFDC_Employee__c where Employee_ID__c=:empNumbertoget];

    List<Employee_Monthly_Info__c> eInfo=[select Employee_Monthly_Info__c.employee__R.name,Medical_Allowance__c,Total_Salary_Amount__c,Net_Salary__c,Total_Deduction__c,Other_Income__c,Loan_Deduction__c,HRA_AMount__c,pt__c,pf__c,Conveyance_Allowance_Amount__c,TDS__c,paid_holidays__c,Total_Casual_Leaves__c,Total_Sick_Leaves__c,basic_salary__c,Leave_with_Pay__c,working_days__c from Employee_Monthly_Info__c where Employee_Monthly_Info__c.employee__R.Employee_ID__c=:empNumbertoget];

    //Retrieve Organization related data

    if(org.size()==0)
    {
         System.debug('org is '+org);
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'Organization details are empty'));
    }

    else
    {
    //Retrieve Organization related data
    orgs=org[0];
    org_Name=orgs.Name;
    org_Address = orgs.Address__c;
    org_email=orgs.email__c;
    org_website=orgs.website__c;

    //Retrieve Employee related data
    employee=emp[0];
    empName = employee.name;
    empNo=employee.Employee_ID__c;
    acleaves=employee.available_casual_leaves__c;
    asleaves=employee.available_sick_leaves__c;
    panNumber =employee.Pan_Number__c;
    Date dat=employee.Start_Date__c;
    doj=String.valueOf(dat);
    designation=employee.Title__c;
    gender=employee.gender__c;
    email=employee.Email_Address__c;
    AccountNumber = employee.Bank_Account_No__c;
    no_days=Date.daysInMonth(d.year(), d.month());

     if(sumLrequest.size() > 0)
    {
       String str = '' + sumLrequest[0].get('s') ;
       lwp= Decimal.ValueOf(str).setScale(0) ;

    }
    if(sumLrequest.size()==null)
    {
       String str = '' + 0;
       lwp= Decimal.ValueOf(str).setScale(0) ;
    }
    //Retrieve Employee monthly Related data
    eMonthInfo=eInfo[0];
   loandeduction =emonthInfo.loan_deduction__c;
    oIncome=eMonthInfo.other_income__c;
    workingDays =eMonthInfo.working_days__c;
   tcleaves=eMonthInfo.total_casual_leaves__c;
    tsleaves=eMonthInfo.total_Sick_leaves__c;
    bSalary=eMonthInfo.basic_salary__c;
    deductions=eMonthInfo.total_deduction__c;
    tsalaryAmount=eMonthInfo.Total_Salary_Amount__c;
    pf=eMonthInfo.pf__c;
    pt=eMonthInfo.pt__c;
    tdeduce=eMonthInfo.total_deduction__c;
    caAmount=eMonthInfo.Conveyance_Allowance_Amount__c;
    hraAmount=eMonthInfo.HRA_Amount__c;
    obAmount=eMonthInfo.Medical_Allowance__c;
    tnetsalary=eMonthInfo.net_salary__c;
    tds=eMonthInfo.tds__c;
    }

}
}
I have an Custom_Object_A__c which has a look up relation with Custom_Object_B__c. 
Custom_Object_A__c has a field NumberS__c (Number(15,0)).
Custom_Object_b__c has a field parentNumber__c((Number(15,0))
When i want to create a new record in Custom_Object_b__c then i need to autopopulate parentNumber__c field with NumberS__c  value. How can i achieve without using URL hack ?
Hi, 

I had three custom fields like available_casual_leaves__c,available_sick_leaves__c and days_off __c on leave_request__c object.
the default values of available_Casual_leaves__c is 20 and available_sick_leaves__c is 10. Now i have to update the default values in both available_casual_leaves__c and available_sick_leaves__c. for that i am writing

trigger availableLeavesTrigger on Leave_Request__c (before Update) {
    List<Leave_Request__c> lr= new List<Leave_Request__c>();
    List< Leave_Request__c> IdsForUpdate = new List< Leave_Request__c>();
    Leave_Request__c lqr=new Leave_Request__c();
    List<leave_request__c> leaveList=new LIST<leave_request__c>();   
    if(trigger.isUpdate)
    {
        for(Leave_Request__c l:trigger.new)
        {
            IdsForUpdate.add(l);
        }       
    }
    for(leave_request__C leave:[Select id,name, type_of_leave__c,Available_casual_leaves__c,
        Available_sick_leaves__c,  days_off__c from Leave_Request__c where id=:IdsForUpdate])
    {
       System.debug('isjfh 0 -- > '+leave);
        if(leave.type_of_leave__C=='casual leave')
        {
            System.debug('0 -- > '+leave);
            leave.available_casual_leaves__c=leave.available_casual_leaves__c-leave.days_off__c;
            System.debug('1 -- > '+leave.available_casual_leaves__c);
            leaveList.add(leave);          
        }
        else if(leave.type_of_leave__c=='sick leave')
        {
            leave.available_sick_leaves__c=leave.available_sick_leaves__c-leave.days_off__c;
            System.debug('2 -- > '+leave.available_sick_leaves__c);
            leaveList.add(leave);
        }
      }
      update leavelist;
  }

but i am not able to see any debug logs and ofcourse the values are not updating could any one tell me where i am going wroing
i have three custom objects.

Bank_Account__c(Parent) --->Bank_transaction__c(child)

Bank_Account__c(Parent) --->Bank_statement__c(child)

Bank_transaction__c fields are date__c, credit__c, debit__c

Bank_statement__c fields are start_date__c, end_date__c

I just want to write a single query to get the records of Bank_transaction__c which date__c is in between start_date__c and end_date__c of bank_statement__c object. How can i achieve this
On the beginning of this month , I scheduled my Dev 401 exam. While i am writing ,In middle of the exam , the exam has been ended saying some error as out of webcam even i am infront of it as per the conditions. I immediatly opened a case and waiting for their reply . And couple of days back i opened another case mentioning the same , but still there is no response. I have my case number. How can i check my case status ? Why does this suspension is done ? what does it mean ? What can i do now ? could any one suggest me
Hello all,

I want to pass the List values of an object to the other Visualforce page using a query. Since we cannot pass list as parameter to other page i am using

public PageReference DisplayDetails() {
      
        PageReference reRend = new PageReference('/apex/wrapperCustomObjpage2');
        reRend.setRedirect(false);
        return reRend;
       
    }

But the variables in the controller were reintializing after entering into the other page. I am not able to display the data into pageblocktable. Could any one suggest me the best approach