• sandeepathadu
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 29
    Replies
this is the trigger i have wriiten 
trigger caseAssignWebCaseToAccountOwner on Case (before update) {
for(case c :trigger.new){
ID profile = [select id from Profile where name = 'System Administrator'].id; 
user u = [Select id,name,IsActive from user where ProfileId =: profile limit 1 ];
if(c.Origin == 'Portal' && c.SSP_owner_Update__c==false && c.accountid!=null && u.isactive == True){
 account a = [select id,name,OwnerId from account where id=:c.accountid];
 c.ownerid=a.ownerID;
 c.SSP_owner_Update__c=true;
}
 else if(c.Origin == 'Portal' && u.isactive == false )
 c.ownerid='005Q0000000f95r';

}
}
the test case i have wriiten getting 87 percent not covering the else part plz help
@istest
private class UpdateTicketOwner_Test
{
static testMethod void MytestClass()
{

  Account a1 = new Account();
  a1.Name='SriRam';
  a1.CurrencyIsoCode='INR';
  a1.Primary_Contact_s_Email__c='SriRam@Y-Axis.com';
  
  insert a1;



  Case c1 = new Case();
  c1.Accountid=a1.id;
  c1.CurrencyIsoCode='INR';
  c1.Status='New';
  c1.Origin='Portal';
  c1.Priority='Medium';
  c1.SSP_owner_Update__c=false;
  
  insert c1;
 

 update c1;
    
  if((c1.Origin == 'Portal')&&(c1.SSP_owner_Update__c==false)&&(c1.accountid!=null))
  {
   c1.ownerid=a1.ownerID;
    c1.SSP_owner_Update__c=true;
  }
  
 }
 
 
 
}
plz help

 

hi all
 
i have written a trigger that will update the account owner name on saving a ticket instead of admin name which is by default
 
for ex: if i save a ticket i get admin name generally but i have written a trigger and instead of admin name it updates account owner name now the issue is when i deactivate the account owner it should update the user name for this i have written this trigger







trigger caseAssignWebCaseToAccountOwner on Case (before update) {
for(case c :trigger.new){
user u = [Select id,name,IsActive from user limit 1 ];
if(c.Origin == 'Portal' && c.SSP_owner_Update__c==false && c.accountid!=null && u.isactive == True){
 account a = [select id,name,OwnerId from account where id=:c.accountid];
 c.ownerid=a.ownerID;
 c.SSP_owner_Update__c=true;
}
  if(c.Origin == 'Portal' && u.isactive == False)
  
 c.ownerid= '005Q0000000f95r';

}
}
but now when i deactivate the account owner and save the ticket it is saying

 
Operation with Inactive UserAn operation was performed with an inactive user. 



plz help how to update the ticket name with the user name when we deactivate a account

 

hi all
 
i have written a trigger that will update the account owner name on saving a ticket instead of admin name which is by default
 
for ex: if i save a ticket i get admin name generally but i have written a trigger and instead of admin name it updates account owner name now the issue is when i deactivate the account owner it should update the user name for this i have written this trigger
trigger caseAssignWebCaseToAccountOwner on Case (before update) {
for(case c :trigger.new){
user u = [Select id,name,IsActive from user limit 1 ];
if(c.Origin == 'Portal' && c.SSP_owner_Update__c==false && c.accountid!=null && u.isactive == True){
 account a = [select id,name,OwnerId from account where id=:c.accountid];
 c.ownerid=a.ownerID;
 c.SSP_owner_Update__c=true;
}
  if(c.Origin == 'Portal' && u.isactive == False)
  
 c.ownerid= '005Q0000000f95r';

}
}
but now when i deactivate the account owner and save the ticket it is saying

 
Operation with Inactive UserAn operation was performed with an inactive user. plz help how to update the ticket name with the user login when we deactivate a account

 

hi all

 

i have written a trigger that will update the account owner name on saving a ticket instead of admin name which is by default

 

for ex: if i save a ticket i get admin name generally but i have written a trigger and instead of admin name it updates account owner name now the issue is when i deactivate the account owner it should update the user name for this i have written this trigger

trigger caseAssignWebCaseToAccountOwner on Case (before update) {
for(case c :trigger.new){
user u = [Select id,name,IsActive from user limit 1 ];
if(c.Origin == 'Portal' && c.SSP_owner_Update__c==false && c.accountid!=null && u.isactive == True){
 account a = [select id,name,OwnerId from account where id=:c.accountid];
 c.ownerid=a.ownerID;
 c.SSP_owner_Update__c=true;
}
  if(c.Origin == 'Portal' && u.isactive == False)
  
 c.ownerid= '005Q0000000f95r';

}
}
but now when i deactivate the account owner and save the ticket it is saying


 

Operation with Inactive UserAn operation was performed with an inactive user. plz help how to update the ticket name with the user login when we deactivate a account

this is my trigger

 

trigger updatetotal on Opportunity (before update, before insert)
{
    Integer i = 0;
    Decimal id2num =0.00;
   Decimal n1=0.00;Decimal n2=0.00,n3=0.00,n4=0.00;
    for (Opportunity o : Trigger.new)
    {
  
   if (Trigger.isUpdate)
        {
   Opportunity[] opp =[select ID,Total_Approved__c,Total_Invoiced__c,Total_Planned__c,Total_Submitted__c,StageName,Amount from Opportunity where Header_Opportunity__c=:o.id and  recordtypeid='012M000000008mu' and StageName='Billing-Invoiced'];
     
     o.Total_Invoiced__c=0.00;
     o.Total_Approved__c=0.00;
     o.Total_Planned__c=0.00;
     o.Total_Submitted__c=0.00;
     
     
        for(Opportunity opp1:opp)
         {              
           n1=opp1.Amount+n1;
           o.Total_Invoiced__c=n1;         
         }
        
     Opportunity[] opp3 =[select ID,Total_Approved__c,Total_Invoiced__c,Total_Planned__c,Total_Submitted__c,StageName,Amount from Opportunity where Header_Opportunity__c=:o.id and  recordtypeid='012M000000008mu' and StageName='Billing-Approved' ];
     for(Opportunity opp13:opp3) 
        {
          n2=opp13.Amount+n2;
          o.Total_Approved__c=n2;}
       
       
     Opportunity[] opp7 =[select ID,Total_Approved__c,Total_Invoiced__c,Total_Planned__c,Total_Submitted__c,StageName,Amount from Opportunity where Header_Opportunity__c=:o.id and  recordtypeid='012M000000008mu' and StageName='Billing-Planned' ];
        
           for(Opportunity opp17:opp7){ 
           n3=opp17.Amount+n3;
           o.Total_Planned__c=n3;
          }
         Opportunity[] opp9 =[select ID,Total_Approved__c,Total_Invoiced__c,Total_Planned__c,Total_Submitted__c,StageName,Amount from Opportunity where Header_Opportunity__c=:o.id and  recordtypeid='012M000000008mu' and  StageName='Billing-Submitted' ];
          for(Opportunity opp19:opp9){ 
          n4=opp19.Amount+n4;
          o.Total_Submitted__c=n4;
          }
      }

       }
     
    }
my test case and i am getting only 68 percent code coverage plz help
@istest
private class updatetotal_Test1 {

  //  static testMethod void SetContactRoleDefaults_Test() {
  //  test.starttest();
  static testMethod void uptotal ()
  {
            Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];
           
            Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true);
            insert pb;
            
            Product2 prod = new Product2(Name = 'Anti-infectives 2007', Family = 'Best Practices', IsActive = true);
            insert prod;
            
            PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
            insert standardPrice;
            
            PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
            insert pbe;
            
            //List <Account> Account ;
            Account a = new account();
            a.Name = 'Powerhouse Electronics';
            insert a;
            
           // Product prod = new Product();
           // prod.Name = 'Product test';
           // insert prod;
            
            //header opportunity
            Opportunity p = new Opportunity();
            p.Name = 'Testing9';
            p.Accountid= a.id;           
            p.ForecastCategoryName='Commit'; 
            p.recordtypeid='012M000000008mp';
            p.StageName='Billing-Approved';
            p.Amount=1000; 
            p.Total_Approved__c=100;
            
            p.CloseDate = date.ValueOf('2009-07-21');
           p.Estimated_Start_Date__c=date.ValueOf('2009-7-21');
           p .Estimated_End_Date__c=date.ValueOf('2009-10-21');
            p.StageFilter__c = 'Billing-Approved';                    
            insert p;
             update p;
            
             decimal n1=0.0;
              n1=p.Amount+100;
              p.Total_Approved__c=n1;
             
              
              
             decimal n2=0.0;
              n2=p.Amount+100;
              p.Total_Planned__c=n1;
             
            
            OpportunitylineItem olitem = new OpportunitylineItem();
            olitem.opportunityid=p.id;
            olitem.TotalPrice=56;
            olitem.quantity=33;
            olitem.PricebookEntryId =pbe.id;          
            insert olitem;
            
            
            Opportunity p1 = new Opportunity();
            p1.Header_Opportunity__c=p.id;
            p1.Name='test9';
            p1.StageName='Billing-Approved';
            p1.recordtypeid='012M000000008mp';
            p1.CloseDate=Date.valueof('2011-07-07');            
            insert p1;
             update p; 
             OpportunitylineItem olitem1 = new OpportunitylineItem();
             olitem1.opportunityid=p1.id;
             olitem1.TotalPrice=56;
             olitem1.quantity=33;
             
             olitem1.PricebookEntryId = pbe.id;        
             insert olitem1; 
              
             
          
  
  
   

                                                
    }
 
}

 

 

this is my class

public class Oppctrldelete
{
    decimal j = 0;

    public Oppctrldelete(ApexPages.StandardController controller) {


this.id =ApexPages.currentPage().getParameters().get('id');
op =[select id,name,Total_Invoiced__c,Total_Approved__c ,Billings_Indicator__c ,StageFilter__c,final_stage__c ,Quote_vs_Billings_Difference__c ,Filterstage__c,Total_Planned__c,Total_Submitted__c,ownerid,Purchase_order__c,Account.name,stagename,CloseDate,amount,probability,Header_Opportunity__c,Accountid,Opp_Line_Items_Count__c,Billing_Contact__c,No_Of_Months_for_Billing__c from Opportunity where id=:id];

oli = [select id,Quantity,delete__c ,description,pricebookentry.name,UnitPrice,TotalPrice ,Opportunityid,Quote_Original_List_Price__c,Product_Code__c   from OpportunityLineItem where opportunityid=:id ORDER BY Quantity];
if(op.StageFilter__c== 'Billing-Planned'){
opps =[select id,ownerid,Final_Stage__c,name,Account.name,stagename,CloseDate,amount,probability,Header_Opportunity__c,Accountid,Opp_Line_Items_Count__c,Billing_Contact__c,No_Of_Months_for_Billing__c,Filterstage__c from Opportunity where Header_Opportunity__c =:op.id ORDER BY closedate];
oppli = [select id,Line_Item_Total__c,Quantity,Quantity__c,PricebookEntryId,delete__c ,TotalPrice ,description,UnitPrice,Opportunityid,Quote_Original_List_Price__c,Product_Code__c   from OpportunityLineItem where opportunityid in: opps ORDER BY Quantity];
}
else if(op.StageFilter__c== 'Billing-Submitted'){
opps =[select id,ownerid,Final_Stage__c,name,Account.name,stagename,CloseDate,amount,probability,Header_Opportunity__c,Accountid,Opp_Line_Items_Count__c,Billing_Contact__c,No_Of_Months_for_Billing__c,Filterstage__c from Opportunity where Header_Opportunity__c =:op.id AND (stagename='Billing-Submitted' OR  stagename='Billing-Approved' OR  stagename='Billing-Invoiced') ORDER BY closedate];
oppli = [select id,Line_Item_Total__c,Quantity,Quantity__c,delete__c ,PricebookEntryId,TotalPrice ,description,UnitPrice,Opportunityid,Quote_Original_List_Price__c,Product_Code__c   from OpportunityLineItem where opportunityid in: opps ORDER BY Quantity];
}
else if(op.StageFilter__c== 'Billing-Approved'){
opps =[select id,ownerid,Final_Stage__c,name,Account.name,stagename,CloseDate,amount,probability,Header_Opportunity__c,Accountid,Opp_Line_Items_Count__c,Billing_Contact__c,No_Of_Months_for_Billing__c,Filterstage__c from Opportunity where Header_Opportunity__c =:op.id  AND  (stagename='Billing-Approved' OR stagename='Billing-Invoiced') ORDER BY closedate];
oppli = [select id,Line_Item_Total__c,PricebookEntryId ,Quantity,Quantity__c,delete__c ,TotalPrice ,description,UnitPrice,Opportunityid,Quote_Original_List_Price__c,Product_Code__c   from OpportunityLineItem where opportunityid in: opps ORDER BY Quantity];
}
else if(op.StageFilter__c== 'Billing-Invoiced'){
opps =[select id,ownerid,Final_Stage__c,name,Account.name,stagename,CloseDate,amount,probability,Header_Opportunity__c,Accountid,Opp_Line_Items_Count__c,Billing_Contact__c,No_Of_Months_for_Billing__c,Filterstage__c from Opportunity where Header_Opportunity__c =:op.id   AND  stagename='Billing-Invoiced' ORDER BY closedate];
oppli = [select id,Line_Item_Total__c,PricebookEntryId,Quantity,Quantity__c,delete__c ,TotalPrice ,description,UnitPrice,Opportunityid,Quote_Original_List_Price__c,Product_Code__c   from OpportunityLineItem where opportunityid in: opps ORDER BY Quantity];
}

 //opadd =[select id, MAX(CloseDate)   from Opportunity Limit 1 ];
//oppli = [select id,Line_Item_Total__c,Quantity,delete__c ,TotalPrice ,description,UnitPrice,Opportunityid,Quote_Original_List_Price__c,Product_Code__c   from OpportunityLineItem where opportunityid in: opps];
  Oppsnew = new List<Opportunity>();
  Opplinew = new List<Opportunitylineitem>();
   

   
    }
// Save The Updates on Opp and LineIems
   
    
   
    public PageReference save()    
     {
     try
     {     
   
         update oppli;
         oppli[0].Fire_Trigger__c = true;
         update Opps;
         //oli[0].Fire_Trigger__c = true;
         update oli;        
         update op;
       }
       
     catch(DmlException ex)
    {
        ApexPages.addMessages(ex);
        return null;
    }     
   return(new ApexPages.StandardController(Op)).view();  
    }


  // Cancel and go Back to Header Opportunity
   public PageReference cancel() 
    {
     return(new ApexPages.StandardController(Op)).view();
        return null;
    }
    
    
    public PageReference addmonthdyn()
     { 
    try
     {
     integer d;
     integer lkj = opps.size();
     integer poi = lkj-1;
 
     OpportunitylineItem[] oli = [select id,TotalPrice,ListPrice,PricebookEntry.name,Quantity,PricebookEntry.Product2.Name , PricebookEntry.Product2.id, UnitPrice,PricebookEntryId,Opportunityid,Quote_Original_List_Price__c  from OpportunityLineItem where Opportunityid=:id ORDER BY Quantity] ;
     opps[poi] =  [select id,Final_Stage__c ,Final_Closed_Date__c,stagename,Description,AccountId ,Hold_My_date__c,Week_End_Day__c ,name,closedate,Estimated_Start_Date__c from Opportunity where Header_Opportunity__c=:op.id ORDER BY closedate DESC LIMIT 1];
   
     Opportunity newopp= new Opportunity();
     newopp.stagename = 'Billing-Planned';
     newopp.Header_Opportunity__c=op.id;     
     newopp.recordtypeid='012M000000008mu';
     string mon;    
       
     decimal x = (poi+1*30);     
     newopp.Hold_My_date__c = opps[poi].closedate +x.intValue();
    
    // LitOrd.closedate = o.closedate;
    // for(Opportunity opps2:opps)
      //{
       //LitOrd.closedate = opps2.closedate+60; 
      // LitOrd.closedate = LitOrd.closedate+30; 
    // }
     newopp.closedate = opps[poi].closedate+30; 
    //LitOrd.closedate = opps[poi].closedate;   
   // Integer currentyear = opps[poi].Hold_My_date__c.year();
   // Integer currentMonth = (opps[poi].Hold_My_date__c.Month())+1;
       Integer currentyear =  newopp.Hold_My_date__c.year();
       Integer currentMonth =  newopp.Hold_My_date__c.Month();
        if(currentMonth==1){
          mon = 'JAN';
          
         
         }
         else if(currentMonth==2){
         mon = 'FEB';
         }
          else if(currentMonth==3){
         mon = 'MAR';
         }
          else if(currentMonth==4){
         mon = 'APR';
         }
          else if(currentMonth==5){
         mon = 'MAY';
         }
          else if(currentMonth==6){
         mon = 'JUN';
         }
          else if(currentMonth==7){
         mon = 'JUL';
         }
          else if(currentMonth==8){
         mon = 'AUG';
         }
          else if(currentMonth==9){
         mon = 'SEP';
         }
          else if(currentMonth==10){
         mon = 'OCT';
         }
          else if(currentMonth==11){
         mon = 'NOV';
         }
          else if(currentMonth==12){
         mon = 'DEC';
         }
        
      newopp.accountid = opps[poi].accountid;
      newopp.name = op.Account.name+'-'+op.Name+'-'+'Billing'+'-'+mon+'-'+ currentyear;
      
      newopp.final_stage__c ='Billing-Planned';
      newopp.probability =100;
      newopp.amount = 100;
     
      Oppsnew.add(newopp); 
      insert oppsnew;
    
    
   
  }
   catch(DmlException ex)
   {
     ApexPages.addMessages(ex);
     return null;
   }
   PageReference customPage = new PageReference('/apex/opptctldelete'); 
   customPage.getParameters().put('id', this.id);
   customPage.setRedirect(true);
   return customPage;
  
    }
    
   
    
   //Quick save changes
   public PageReference quicksave()
   {
     try
     {    
    

        update oppli;
        oppli[0].Fire_Trigger__c = true;
        update Opps;
        //oli[0].Fire_Trigger__c = true;
        update oli;        
        update op;
       
     
    
    }
    catch(DmlException ex)
    {
        ApexPages.addMessages(ex);
        return null;
    }
     
   PageReference customPage = new PageReference('/apex/opptctldelete');   
   customPage.getParameters().put('id', this.id);
   customPage.setRedirect(true);
   return customPage;             
    }   

  
    
   public List<Opportunity> Oppsnew  {get; set;} 
   public List<Opportunitylineitem> Opplinew  {get; set;} 
   public Opportunity Op ;
   public Opportunity opadd;
   public Opportunity[] Opps ;
   public OpportunitylineItem[] Oppli ;
   public OpportunitylineItem[] Oli ;
   public string id;
   decimal gtotal=0.0;
   decimal itotal=0;
   user u;
   decimal countindvidual;
   decimal actualcountindvidual;  
   decimal BItotal;
   decimal count = 0; 
   decimal finalBItotal =0;
   decimal counttotal = 0;
   decimal  totval;
   decimal childtot=0.0;

public String getname()
{
return 'Oppctrldelete';
}
public Opportunity getop()
{
return op;
}
public user getu()
{
return u;
}
public Opportunity [] getopps()
{

return opps;
}


 public PageReference filterstage()
  {
 update op;
   
  PageReference customPage = new PageReference('/apex/opptctldelete');   
  customPage.getParameters().put('id', this.id);
  customPage.setRedirect(true);
  return customPage; 
            
    }   



public OpportunitylineItem[] getoppli()
{

return oppli;
}
public OpportunitylineItem[] getoli()
{

return oli;
}

 
 
  public decimal gettotval()
 {
return totval;
}
public decimal getcountindvidual() {
return countindvidual;
}
 public decimal getgtotal()
 {
return gtotal;
} 
public decimal getBItotal()
 {
return BItotal;
} 
}
this is my test case giving 79 percent code coverage and the else conditions are not getting covered plz help me to write test case in easiest possible way
@isTest
private class Oppctrldelete_Test
{
static testmethod void MyTestController()
 {

        Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];

        Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true);
        insert pb;
        
        Product2 prod = new Product2(Name = 'Anti-infectives 2007', Family = 'Best Practices', IsActive = true);
        insert prod;

        PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert standardPrice;

        PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert pbe;
         
 Account a = new Account();
 a.name = 'raja';
 insert a ;
 
  
 Opportunity opp = new Opportunity();
 opp.Name = 'raja';
 opp.StageName = 'Closedwon';
 opp.final_stage__c= 'Billing-Planned';
 opp.StageFilter__c = 'Billing-Submitted';
 
 opp.StageFilter__c = 'Billing-Planned';
 
 
 opp.CloseDate = date.ValueOf('2009-09-21');
 opp.Pricebook2Id = pb.id;
 opp.final_stage__c ='Billing-Invoiced';
 
 
 test.startTest();

 insert opp;
   
   test.stopTest();

   
   
   
   
   
   
     OpportunitylineItem opli = new OpportunitylineItem();
  opli.opportunityid=opp.id;
  opli.TotalPrice=5;
  opli.quantity=3;
  opli.PricebookEntryId = pbe.id; 
  
 insert opli;
     
   
   

      
 Opportunity opp1 = new Opportunity();
 opp1.Name = 'raj';
 opp1.StageName = 'Closedwon';
 opp1.StageFilter__c= 'Billing-Planned';
 opp1.CloseDate = date.ValueOf('2009-07-21');
 opp1.final_stage__c= 'Billing-Planned';
 opp1.Pricebook2Id = pb.id;
 opp1.header_opportunity__c = opp.id;
 insert opp1;
 
 
 
 
 
  
  OpportunitylineItem opli1 = new OpportunitylineItem();
  opli1.opportunityid=opp1.id;
  opli1.TotalPrice=56;
  opli1.quantity=33;
  opli1.PricebookEntryId = pbe.id; 
 opli1.delete__c=true;
  insert opli1;
  update opli;
    update opli1;
    
    
    
    
       
 ApexPages.currentPage().getParameters().put('id', opp.id);

 
 
 
  
 ApexPages.StandardController con = new ApexPages.StandardController(opp);
 Oppctrldelete o = new Oppctrldelete(con);
 
 
 PageReference pr2 = o.save();
 PageReference pr3 = o.addmonthdyn();
 PageReference pr4 = o.quicksave();
//  PageReference pr5 = o.testsave();
 o.getname();
 o.getopps();
 o.filterstage();
 o.getoppli();
 o.getop();
 O.getu();
 o.getoli();
 o.getcountindvidual();
 o.getgtotal();
 o.getBItotal();
 o.gettotval();
 o.cancel();
 //o.Addmonth();
// o.incrementCounter();
// o.quan();
 //o.childtotal();
// o.BI();
 //o.grandtotal();
  
  
 
 
 
  }
 }

 

 

plz help me how to cover the else condition in salesforce

hi all 

plz rewrite my code to avoid too many script statements error

public class Dev_From_To_Ctrl
{
public Dev_From_To_Ctrl(ApexPages.StandardController controller) 
{ 
userInputAppointment = new Appointment__c();

}
public Appointment__c userInputAppointment {get; set;}
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps1 {get;set;}  
public list<appointment__c> apps2 {get;set;}
public list<appointment__c> apps3 {get;set;}
public list<appointment__c> apps4 {get;set;}
public list<appointment__c> apps5 {get;set;}
public list<appointment__c>  getall {get;set;}



/*code starts from here
first scenario----from hour less than to hour   ex:8<9 8<15 
sub scenarios in first scenario
ex: from   8:10  to   12:50

scenario 1)8:10 to 8:50
scenario 2)9:00 to 9:50 & 10:00 to 10:50 &11:00 to 11:50
scenario 3)12:00 to   12:50*/




public PageReference save()
{
apps = new list<appointment__c>();
apps1 = new list<appointment__c>();
apps2 = new list<appointment__c>();
apps3 = new list<appointment__c>();
apps4 = new list<appointment__c>();
apps5 = new list<appointment__c>();
string j=userInputAppointment.Appt_24_From_Min__c;
string v =userInputAppointment.Appt_24_To_Min__c;
integer i=integer.valueof(userInputAppointment.Appt_24_From_Hour__c);          
integer i1=integer.valueof(userInputAppointment.Appt_24_To_Hour__c);
integer i2=integer.valueof(userInputAppointment.Appt_24_From_Min__c);
integer i3=integer.valueof(userInputAppointment.Appt_24_To_Min__c);

if(i<i1)
{ 

//scenerio 1 i.e 8:10 to 8:50 stars here
for(integer k=0;k<(60-i2)/10;k++)
{
//first take the given values by user



appointment__c ap = new appointment__c();
ap.Appt_24_From_Hour__c=String.valueOf(i);
ap.Appt_24_To_Hour__c=String.valueOf(i1);
ap.Appt_24_From_Min__c=String.valueOf(j);
ap.Appt_24_To_Min__c=String.valueOf(v);
ap.Dev_Appt_Type_Normal_Or_From_To__c   =true;
ap.branch__c =  userInputAppointment.branch__c;
ap.account__c = userInputAppointment.Account__c;
ap.doctor__c=userInputAppointment.doctor__c;
ap.appt_date__c = userInputAppointment.appt_date__c;
ap.Appt_AM_PM__c= 'AM';
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>=12)
{
ap.Appt_AM_PM__c= 'PM';
}
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>12)
{
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)-12);
}
ap.Appt_Minute__c = userInputAppointment.Appt_24_From_Min__c;
ap.RecordTypeid=userInputAppointment.RecordTypeid;
if(i2!=integer.valueof(userInputAppointment.Appt_24_From_Min__c))
{
//LIVE ID
       // app1.RecordTypeid='01290000000ZXNL';
       
       //SB ID
       ap.RecordTypeid='012N0000000CgZ2';
       
}
apps1.add(ap);
}
insert apps1[0];


// here the first record in the list

userInputAppointment.Appt_24_From_Min__c=String.valueOf(i2);
for(integer k=0;k<(50-i2)/10;k++)
{
appointment__c ap8 = new appointment__c();

ap8.Appt_24_From_Hour__c=String.valueOf(i);
ap8.Appt_24_To_Hour__c=String.valueOf(i1);
ap8.Appt_24_From_Min__c=String.valueOf(j);
ap8.Appt_24_To_Min__c=String.valueOf(v);
ap8.Dev_Appt_Type_Normal_Or_From_To__c   =true;
ap8.branch__c =  userInputAppointment.branch__c;
ap8.account__c = userInputAppointment.Account__c;
ap8.doctor__c=userInputAppointment.doctor__c;
ap8.appt_date__c = userInputAppointment.appt_date__c;
ap8.Appt_AM_PM__c= 'AM';
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>=12)
{
ap8.Appt_AM_PM__c= 'PM';
}
ap8.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>12)
{
ap8.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)-12);
}
ap8.Appt_Minute__c = String.valueOf( integer.valueof(userInputAppointment.Appt_24_From_Min__c)+10);
//LIVE ID
       // app1.RecordTypeid='01290000000ZXNL';
       
       //SB ID
       ap8.RecordTypeid='012N0000000CgZ2';
       
ap8.Dev_Parent_Appt__c=apps1[0].id;
apps4.add(ap8);
userInputAppointment.Appt_24_From_Min__c=String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Min__c)+10);
}
insert apps4;

//scenerio 1 i.e 8:10 to 8:50 ends here


//scenario 2 starts here   i.e  9:00 to 9:50 & 10 to 10:50 &11:00 to 11:50




for( integer l=1;l<i1-i;l++)
{
userInputAppointment.Appt_24_From_Hour__c=String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)+1);
string x='00';
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)<integer.valueof(userInputAppointment.Appt_24_To_Hour__c))
{
for(integer g=0;g<6;g++)
{
appointment__c ap1=new appointment__c();
ap1.Appt_24_From_Hour__c=String.valueOf(i);
ap1.Appt_24_To_Hour__c=String.valueOf(i1);
ap1.Appt_24_From_Min__c=String.valueOf(j);
ap1.Appt_24_To_Min__c=String.valueOf(v);
ap1.Dev_Appt_Type_Normal_Or_From_To__c   =true;
ap1.Appt_24_From_Hour__c=userInputAppointment.Appt_24_From_Hour__c;
ap1.Appt_24_To_Hour__c=userInputAppointment.Appt_24_To_Hour__c;
ap1.Appt_24_From_Min__c=userInputAppointment.Appt_24_From_Min__c;
ap1.Appt_24_To_Min__c=userInputAppointment.Appt_24_To_Min__c;
ap1.branch__c =  userInputAppointment.branch__c;
ap1.account__c = userInputAppointment.Account__c;
ap1.appt_date__c = userInputAppointment.appt_date__c;
ap1.doctor__c=userInputAppointment.doctor__c;
ap1.Appt_AM_PM__c= 'AM';
//LIVE ID
       // app1.RecordTypeid='01290000000ZXNL';
       
       //SB ID
       ap1.RecordTypeid='012N0000000CgZ2';
       
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>=12)
{
ap1.Appt_AM_PM__c= 'PM';
}
ap1.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>12)
{
ap1.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)-12);
}
ap1.Appt_Minute__c=x;
ap1.Dev_Parent_Appt__c=apps1[0].id;
apps2.add(ap1);
x=String.valueOf(integer.valueof(x)+10);
}
}
}
insert apps2;

//scenario 2 ends here   i.e  9:00 to 9:50 & 10 to 10:50 &11:00 to 11:50


//scenario 3  i.e 12:00 to   12:50 stars here






string q='00';


userInputAppointment.Appt_24_From_Hour__c=String.valueOf(i+(i1-i));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)==integer.valueof(userInputAppointment.Appt_24_To_Hour__c))
{
for(integer b=0;b<((i3/10));b++)
{
appointment__c ap3=new appointment__c();
ap3.Appt_24_From_Hour__c=String.valueOf(i);
ap3.Appt_24_To_Hour__c=String.valueOf(i1);
ap3.Appt_24_From_Min__c=String.valueOf(j);
ap3.Appt_24_To_Min__c=String.valueOf(v);
ap3.Dev_Appt_Type_Normal_Or_From_To__c   =true;
ap3.account__c = userInputAppointment.Account__c;
ap3.branch__c =  userInputAppointment.branch__c;
ap3.doctor__c=userInputAppointment.doctor__c;
//LIVE ID
       // app1.RecordTypeid='01290000000ZXNL';
       
       //SB ID
       ap3.RecordTypeid='012N0000000CgZ2';
       
ap3.appt_date__c = userInputAppointment.appt_date__c;
ap3.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>12)
{
ap3.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)-12);
}
ap3.Appt_AM_PM__c= 'AM';
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>=12)
{
ap3.Appt_AM_PM__c= 'PM';
}
ap3.Dev_Parent_Appt__c=apps1[0].id;
ap3.Appt_Minute__c=q;
ap3.Dev_Parent_Appt__c=apps1[0].id;
apps3.add(ap3);
q=String.valueOf(integer.valueof(q)+10);
}
}  
}
insert apps3;

//scenario 3  i.e 12:00 to   12:50 ends here

 

hi i have wriiten a code which contains 6 insert statements it is working fine for me in sandbox but when we are doing migration its failing and giving too many script statements please help me resolve this issue

public class addpro1
{
 public List<OpportunitylineItem> Oppline  {get; set;}
  
  public Opportunity userip {get; set;} 
  
  public Opportunity Opadd ;
public OpportunitylineItem[] Oliadd ;
public Opportunity  bil;
public string id;

  public addpro1(ApexPages.StandardController controller)
   {
this.id =ApexPages.currentPage().getParameters().get('id');

system.debug('id'+this.id);
opadd =[select id,name,Total_Invoiced__c,Total_Approved__c ,StageFilter__c,final_stage__c ,Quote_vs_Billings_Difference__c ,Filterstage__c,Total_Planned__c,Total_Submitted__c,ownerid,Purchase_order__c,Account.name,stagename,CloseDate,amount,probability,Header_Opportunity__c,Accountid,Opp_Line_Items_Count__c,Billing_Contact__c,No_Of_Months_for_Billing__c from Opportunity where id=:id];
system.debug('id'+opadd.id);
bil=[select id, name,oppcheckbox__c  from opportunity where id=:opadd.Header_opportunity__c];
oliadd = [select id,Quantity,delete__c ,description,pricebookentry.name,UnitPrice,TotalPrice ,Foraddingproduct__c,Opportunityid,Quote_Original_List_Price__c,Product_Code__c   from OpportunityLineItem where opportunityid=:bil.id];
//oliadd = [select id,Quantity,delete__c ,description,pricebookentry.name,UnitPrice,TotalPrice ,Foraddingproduct__c,Opportunityid,Quote_Original_List_Price__c,Product_Code__c   from OpportunityLineItem where opportunityid=:id];
     Oppline = new List<OpportunitylineItem>();
       
  userip = new Opportunity();
   }
 
 public PageReference Ad() 

{
//for(Opportunity opadd1:opadd)
//{

  for(Opportunitylineitem oli1 :oliadd)
  {
        if( oli1.Foraddingproduct__c == true)
        {
        OpportunityLineItem olt = new OpportunityLineItem(); 
        olt.opportunityid =opadd.id; 
        olt.PricebookEntryId=oli1.PricebookEntryId; 
        
        olt.Product_Code__c =oli1.PricebookEntry.name;
        olt.quantity =oli1.Quantity;
        olt.unitprice = oli1.UnitPrice;
        olt.description=oli1.description;     
        Oppline.add(olt);
      
        }
     }  
  
//}
 insert  Oppline; 
 
   PageReference customPage = new PageReference('/apex/opptctldelete'); 
 
   customPage.getParameters().put('id', bil.id);
   customPage.setRedirect(true);
   return customPage; 
  
          

}
public PageReference cancelgoback() 

{

   PageReference customPage = new PageReference('/apex/opptctldelete'); 
 
   customPage.getParameters().put('id', bil.id);
   customPage.setRedirect(true);
   return customPage; 
  
          

}


public OpportunitylineItem[] getoliadd()
{
return oliadd;
}


}

 

plz help me when i redirect my first visual force page to the second on button click go to list the second visual force page should automatically get the values of the doctor and branch that are given in my first vsp so plz help me in this whr i should do it in my code
 
 
 
 
 
my first visual force page
 
<apex:page standardController="Appointment__c"  sidebar="false" showHeader="false"  >
<center>
<apex:form > 
Branch:<apex:inputField id="branch" value="{!Appointment__c.Branch__c}"/><br/>
Doctor:<apex:inputField id="doctor" value="{!Appointment__c.Doctor__c}"/><br/>


 <apex:commandButton value="GO" action="/apex/calander?br={!appointment__c.branch__c}&dr={!Appointment__c.Doctor__c}&brname={!appointment__c.BRANCH__R.NAME}"/>
<apex:commandButton value="GO to list" action="/apex/Dev_Doctor_Based_Appt?br={!appointment__c.branch__c}&dr={!Appointment__c.Doctor__c}"/> 

</apex:form>
 </center>
</apex:page>
 now my second visual force page
 
<html>
 
 
<apex:page standardController="Appointment__c" extensions="Dev_Doctor_Based_ApptController" sidebar="false" tabStyle="Doctor_Appts__tab">

<apex:form >



  <table border='0' cellpadding='0' cellspacing='0'>
  
  <tr>
 <td width='400px'><b><apex:outputLink value="/apex/Dev_Doctor_Based_Appt">Doctor Appointments Static</apex:outputLink></b></td>
 
  <td width='60px'>
  
  <b>BRANCH</b>&nbsp;<apex:inputField value="{!userInputAppointment.Branch__c}"/><br/>
 </td>
 <td width='60px'>
 <b>DATE</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<apex:inputField value="{!userInputAppointment.Appt_Date__c}"/><br/>
  </td></tr>
  <tr>
  <td width='400px'><apex:outputLink value="/apex/Dev_Dyn_Doctor_Based_Appt">Doctor Appointments Dynamic</apex:outputLink></td>
  <td width='60px'>
  <b>DOCTOR</b>&nbsp;<apex:inputText id="searchText" value="{!searchText}"/><br/>
 </td>
 <td width='60px'>
  <b>PATIENT</b>&nbsp;<apex:inputText id="searchText1" value="{!searchText1}"/><br/>
 </td>
 
 
 </tr>
 <tr><td width='400px'><apex:outputLink value="/apex/Dev_Transaction_Based">Trans Appointments Static</apex:outputLink></td>
 <td width='200px' align ='center'>
<apex:commandButton value="GO" action="{!load}"/>

</td>
 
 
 </tr>
 <tr align='left'>
 <td width='400px'>
 <apex:outputLink value="/apex/Dev_Dyn_Transaction_Based">Trans Appointments Dynamic</apex:outputLink></td>
 
 <td width='200px'>

<apex:outputPanel rendered="{!IF((searchText1 !=null),true,false)}">
<apex:commandButton value="CHECK IN" action="{!checkin}"/>
<apex:commandButton value="CHECK OUT " action="{!checkout}"/>
<apex:commandButton value="CANCEL APPT" action="{!cancelled}"/>
</apex:outputPanel>
</td>
 
 

 
 </tr>

 </table>
 <br/>
  <br/>
  <br/>
 
controller for my second visual force page
 
public with sharing class Dev_Doctor_Based_ApptController {

    public Dev_Doctor_Based_ApptController(ApexPages.StandardController controller) {
    userInputAppointment = new Appointment__c();
   
  user u= [select id,name,Formula_Branch__c,branch__c  from user where id=:UserInfo.getUserId()];
   Branch__c[] b = [select id,name from branch__c where name =:u.Formula_Branch__c or name = null];
   if(u.Formula_Branch__c != null){
       userInputAppointment.Branch__c = b[0].id;
       searchText4  = 'NONE';
       
   }
  
    }

  public List<appointment__c> appointments {get;set;}  
 
  public List<appointment__c> appttimes {get;set;}  
  
  public List<staff__c> doctors {get;set;} 
 
 
   
  public Appointment__c userInputAppointment {get; set;}
  //Array to hold Doctors
  public String[] rtypes {get;set;}
 // Array to hold Appointment Times
  public String[] timekl {get;set;}
  public String[] timekl1 {get;set;}
  public user ux{get;set;}
  public string searchText  {get;set;}
  public string searchText1 {get;set;}
  public string searchText2 {get;set;}
  public string searchText3 {get;set;}
  public string searchText4 {get;set;}
  
  // start code changes 
  
  public String getname() {
  
    return 'Dev_Doctor_Based_ApptController';
}
// end code changes

 
 // public void load() {
 
         public PageReference load() {
        //Get all The doctors
         doctors =[select id,name from staff__c];
        
         ux= [select id,name,Formula_Branch__c,branch__c  from user where id=:UserInfo.getUserId()];
      
      
       //Get the Appointment Time slots
        appttimes =[Select appt_time__c,RecordType.Name,RecordType.id from appointment__c where RecordType.id ='01290000000YEi3'];
  
       // Get all Appontments for the Doctors
  
  

 appointments =[Select  id,
 name,
 Cancelled__c,
 branch__c,
 Check_In__c,
 Account__r.Phone,
 Check_Out__c,
 RecordType.Name,
 account__r.name,
 Account__c,
 doctor__c,
 Appt_Date__c,
 Staff_Alias__c,Appt_status__c,
 doctor__r.id,
 appt_time__c,
 Appt_Description__c,
 branch__r.name,
 doctor__r.name  
 
  // From appointment__c where (((branch__c = :userInputAppointment.branch__c and Appt_Date__c = :userInputAppointment.Appt_Date__c and RecordType.id !='01290000000YEi3')) and (doctor__r.name like:searchtext+'%' AND ACCOUNT__R.NAME LIKE:SEARCHTEXT1+'%' ))];     
//From appointment__c where (((branch__c = :userInputAppointment.branch__c and Appt_Date__c = :userInputAppointment.Appt_Date__c and RecordType.id !='01290000000YEi3')) and (doctor__r.name like:searchtext+'%' AND ACCOUNT__R.NAME LIKE:SEARCHTEXT1+'%'AND Recordtype.name LIKE:SEARCHTEXT2+'%'))];     
 
  //From appointment__c where ((((branch__c = :userInputAppointment.branch__c and Appt_Date__c = :userInputAppointment.Appt_Date__c and RecordType.id !='01290000000YEi3') and (doctor__r.name like:searchtext+'%' AND ACCOUNT__R.NAME LIKE:SEARCHTEXT1+'%') AND (Check_in__c =: userInputAppointment.Check_in__c AND Check_Out__c =: userInputAppointment.Check_Out__c AND Cancelled__c =: userInputAppointment.Cancelled__c))))]; 
 From appointment__c where (((branch__c = :userInputAppointment.branch__c and Appt_Date__c = :userInputAppointment.Appt_Date__c and RecordType.id !='01290000000YEi3')) and (doctor__r.name like:searchtext+'%' AND ACCOUNT__R.NAME LIKE:SEARCHTEXT1+'%'AND Recordtype.name LIKE:SEARCHTEXT2+'%' and Appt_status__c LIKE:SEARCHTEXT3+'%' and (NOT Recordtype.name LIKE:SEARCHTEXT4+'%')))];     
    // dynamically create set of unique Doctors from query
    Set<String> rtypeset = new Set<String>();
   
    for (appointment__c a : appointments)
      rtypeset.add(a.doctor__r.name);
      
   // dynamically create set of unique Appointment times from query
   Set<String> timeset = new Set<String>();
   
    for (appointment__c a : appttimes)
      timeset.add(a.appt_time__c);
   
   
   //subhash on 18 may 
   Set<String> timeset1 = new Set<String>();
   
    for (appointment__c a : appointments)
      timeset1.add(a.appt_time__c);
   
    timekl1  = new String[timeset1.size()];
    Integer t = 0;
    for (String state1 : timeset1) { 
      timekl1[t] = state1;
      t++;
      
    } 
    timekl1.sort();
   //stop subhash
   
    // convert the set into a string array  
    rtypes = new String[rtypeset.size()];
    Integer i = 0;
    for (String state : rtypeset) { 
      rtypes[i] = state;
            i++;
    }
    rtypes.sort();
    
    // convert the set into a string array  
   timekl  = new String[timeset.size()];
    Integer j = 0;
    for (String state1 : timeset) { 
      timekl[j] = state1;
      j++;
      
    } 
  
    
   
    
    timekl.sort();
    return null;
   
   }
   //mass cancel the appts by filtered search
 public PageReference cancelled() {
 for(appointment__c app:appointments){
 if(searchText1 != null && app.Check_Out__c !=true && app.Check_In__c !=true){
 app.Cancelled__c = true;
 }
 }
 update appointments;
 return null;
 }
  //mass chk out the appts by filtered search
 public PageReference checkout() {
 for(appointment__c app:appointments){
 if(searchText1 != null && app.Cancelled__c !=true && app.Check_In__c == true){
 app.Check_Out__c = true;
 }
 }
 update appointments;
 return null;
 }
  //mass chk in the appts by filtered search
 public PageReference checkin() {
 
 for(appointment__c app:appointments){
 if(searchText1 != null && app.Cancelled__c !=true){
 app.Check_In__c = true;
  }
  
 }
   
 update appointments;
 

 
 
 
 return null;
 
  }
 
 

 

plz help me how to write test case for my trigger

trigger Dev_update_Appt on Appointment__c(after update)
{
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps5 {get;set;} 
apps5 = new list<appointment__c>();
apps = new list<appointment__c>();

Map<ID , appointment__c> mapAppiontment = new MAP<ID , appointment__c>([select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c, Dev_Parent_Appt__c from appointment__c where 

id in: trigger.old]);

List<appointment__c> listApp = new List<appointment__c>();

MAP<ID , List<appointment__c>> mapAPPID_List = new MAP<ID , List<appointment__c>>();
for(appointment__c appObj : [select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c,Dev_Parent_Appt__c from appointment__c where   Dev_Parent_Appt__c in: 

mapAppiontment.keyset()])
{
  if(mapAPPID_List.containskey(appObj.Dev_Parent_Appt__c))
     {
         listApp = mapAPPID_List.get(appObj.Dev_Parent_Appt__c);
     }
   else
     {
        listApp = new List<appointment__c>();
     }
  
  listApp.add(appObj);
  mapAPPID_List.put(appObj.Dev_Parent_Appt__c , listApp);

}

for(Appointment__c o:Trigger.old )
{   

if (Trigger.isUpdate)
{
appointment__c  app1 = mapAppiontment.get(o.id);
List<appointment__c>  app  = new List<appointment__c>();

if(mapAPPID_List.containsKey(app1.id))
   app = mapAPPID_List.get(app1.id);

for(appointment__c ap:app)
{
ap.branch__c=app1.branch__c;
ap.Doctor__c=app1.Doctor__c;
ap.Appt_Date__c=app1.Appt_Date__c; 
apps.add(ap);
}
} 
}
update apps;
}

 my test case i have written i am getting 60 percent 

@isTest
private class updateclass
{

static testmethod void TestController() 
{

Staff__c s1 = new Staff__c();
      s1.name='Rahul';
      s1.Mobile__c='9849098490';
      insert s1;


Branch__c b = new Branch__c();
b.Name = 'Test';
b.Region__c = 'Market Price';
insert b;


Account a = new Account ();
a.LastName = 'Test';
a.Branch__c = b.id;
a.PersonMobilePhone = '9550412970';
insert a ;







    Appointment__c app2 = new Appointment__c();
      app2.account__c=a.id;
      
      //app2.Dev_Parent_Appt__c=app1.id;
      
      
         app2.from__c='6';
        
        app2.from_min__c = '00';
        app2.Appt_AM_PM__c='PM';
        app2.Appt_Date__c=date.ValueOf('2011-05-21');
        app2.Appt_Hour__c='9';
        app2.Appt_Minute__c='80';
        app2.RecordTypeid='012N0000000CgZ2';
       
        app2.Branch__c=b.id;
        app2.to_Min__c='40';
        app2.to__c='7';
          insert app2;
       update app2 ;
       
      
       }
       }

 plz help me to resolve my issue

plz help me when i redirect my first visual force page to the second on button click go to list the second visual force page should automatically get the values of the doctor and branch so plz help me in this whr i should do it in my code

 

 

 

 

 

my first visual force page

 

<apex:page standardController="Appointment__c"  sidebar="false" showHeader="false"  >
<center>
<apex:form > 
Branch:<apex:inputField id="branch" value="{!Appointment__c.Branch__c}"/><br/>
Doctor:<apex:inputField id="doctor" value="{!Appointment__c.Doctor__c}"/><br/>


 <apex:commandButton value="GO" action="/apex/calander?br={!appointment__c.branch__c}&dr={!Appointment__c.Doctor__c}&brname={!appointment__c.BRANCH__R.NAME}"/>
<apex:commandButton value="GO to list" action="/apex/Dev_Doctor_Based_Appt?br={!appointment__c.branch__c}&dr={!Appointment__c.Doctor__c}"/> 

</apex:form>
 </center>
</apex:page>

 now my second visual force page

 

<html>

 

 

<apex:page standardController="Appointment__c" extensions="Dev_Doctor_Based_ApptController" sidebar="false" tabStyle="Doctor_Appts__tab">

<apex:form >



  <table border='0' cellpadding='0' cellspacing='0'>
  
  <tr>
 <td width='400px'><b><apex:outputLink value="/apex/Dev_Doctor_Based_Appt">Doctor Appointments Static</apex:outputLink></b></td>
 
  <td width='60px'>
  
  <b>BRANCH</b>&nbsp;<apex:inputField value="{!userInputAppointment.Branch__c}"/><br/>
 </td>
 <td width='60px'>
 <b>DATE</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<apex:inputField value="{!userInputAppointment.Appt_Date__c}"/><br/>
  </td></tr>
  <tr>
  <td width='400px'><apex:outputLink value="/apex/Dev_Dyn_Doctor_Based_Appt">Doctor Appointments Dynamic</apex:outputLink></td>
  <td width='60px'>
  <b>DOCTOR</b>&nbsp;<apex:inputText id="searchText" value="{!searchText}"/><br/>
 </td>
 <td width='60px'>
  <b>PATIENT</b>&nbsp;<apex:inputText id="searchText1" value="{!searchText1}"/><br/>
 </td>
 
 
 </tr>
 <tr><td width='400px'><apex:outputLink value="/apex/Dev_Transaction_Based">Trans Appointments Static</apex:outputLink></td>
 <td width='200px' align ='center'>
<apex:commandButton value="GO" action="{!load}"/>

</td>
 
 
 </tr>
 <tr align='left'>
 <td width='400px'>
 <apex:outputLink value="/apex/Dev_Dyn_Transaction_Based">Trans Appointments Dynamic</apex:outputLink></td>
 
 <td width='200px'>

<apex:outputPanel rendered="{!IF((searchText1 !=null),true,false)}">
<apex:commandButton value="CHECK IN" action="{!checkin}"/>
<apex:commandButton value="CHECK OUT " action="{!checkout}"/>
<apex:commandButton value="CANCEL APPT" action="{!cancelled}"/>
</apex:outputPanel>
</td>
 
 

 
 </tr>

 </table>
 <br/>
  <br/>
  <br/>
 
controller for my second visual force page
 
public with sharing class Dev_Doctor_Based_ApptController {

    public Dev_Doctor_Based_ApptController(ApexPages.StandardController controller) {
    userInputAppointment = new Appointment__c();
   
  user u= [select id,name,Formula_Branch__c,branch__c  from user where id=:UserInfo.getUserId()];
   Branch__c[] b = [select id,name from branch__c where name =:u.Formula_Branch__c or name = null];
   if(u.Formula_Branch__c != null){
       userInputAppointment.Branch__c = b[0].id;
       searchText4  = 'NONE';
       
   }
  
    }

  public List<appointment__c> appointments {get;set;}  
 
  public List<appointment__c> appttimes {get;set;}  
  
  public List<staff__c> doctors {get;set;} 
 
 
   
  public Appointment__c userInputAppointment {get; set;}
  //Array to hold Doctors
  public String[] rtypes {get;set;}
 // Array to hold Appointment Times
  public String[] timekl {get;set;}
  public String[] timekl1 {get;set;}
  public user ux{get;set;}
  public string searchText  {get;set;}
  public string searchText1 {get;set;}
  public string searchText2 {get;set;}
  public string searchText3 {get;set;}
  public string searchText4 {get;set;}
  
  // start code changes 
  
  public String getname() {
  
    return 'Dev_Doctor_Based_ApptController';
}
// end code changes

 
 // public void load() {
 
         public PageReference load() {
        //Get all The doctors
         doctors =[select id,name from staff__c];
        
         ux= [select id,name,Formula_Branch__c,branch__c  from user where id=:UserInfo.getUserId()];
      
      
       //Get the Appointment Time slots
        appttimes =[Select appt_time__c,RecordType.Name,RecordType.id from appointment__c where RecordType.id ='01290000000YEi3'];
  
       // Get all Appontments for the Doctors
  
  

 appointments =[Select  id,
 name,
 Cancelled__c,
 branch__c,
 Check_In__c,
 Account__r.Phone,
 Check_Out__c,
 RecordType.Name,
 account__r.name,
 Account__c,
 doctor__c,
 Appt_Date__c,
 Staff_Alias__c,Appt_status__c,
 doctor__r.id,
 appt_time__c,
 Appt_Description__c,
 branch__r.name,
 doctor__r.name  
 
  // From appointment__c where (((branch__c = :userInputAppointment.branch__c and Appt_Date__c = :userInputAppointment.Appt_Date__c and RecordType.id !='01290000000YEi3')) and (doctor__r.name like:searchtext+'%' AND ACCOUNT__R.NAME LIKE:SEARCHTEXT1+'%' ))];     
//From appointment__c where (((branch__c = :userInputAppointment.branch__c and Appt_Date__c = :userInputAppointment.Appt_Date__c and RecordType.id !='01290000000YEi3')) and (doctor__r.name like:searchtext+'%' AND ACCOUNT__R.NAME LIKE:SEARCHTEXT1+'%'AND Recordtype.name LIKE:SEARCHTEXT2+'%'))];     
 
  //From appointment__c where ((((branch__c = :userInputAppointment.branch__c and Appt_Date__c = :userInputAppointment.Appt_Date__c and RecordType.id !='01290000000YEi3') and (doctor__r.name like:searchtext+'%' AND ACCOUNT__R.NAME LIKE:SEARCHTEXT1+'%') AND (Check_in__c =: userInputAppointment.Check_in__c AND Check_Out__c =: userInputAppointment.Check_Out__c AND Cancelled__c =: userInputAppointment.Cancelled__c))))]; 
 From appointment__c where (((branch__c = :userInputAppointment.branch__c and Appt_Date__c = :userInputAppointment.Appt_Date__c and RecordType.id !='01290000000YEi3')) and (doctor__r.name like:searchtext+'%' AND ACCOUNT__R.NAME LIKE:SEARCHTEXT1+'%'AND Recordtype.name LIKE:SEARCHTEXT2+'%' and Appt_status__c LIKE:SEARCHTEXT3+'%' and (NOT Recordtype.name LIKE:SEARCHTEXT4+'%')))];     
    // dynamically create set of unique Doctors from query
    Set<String> rtypeset = new Set<String>();
   
    for (appointment__c a : appointments)
      rtypeset.add(a.doctor__r.name);
      
   // dynamically create set of unique Appointment times from query
   Set<String> timeset = new Set<String>();
   
    for (appointment__c a : appttimes)
      timeset.add(a.appt_time__c);
   
   
   //subhash on 18 may 
   Set<String> timeset1 = new Set<String>();
   
    for (appointment__c a : appointments)
      timeset1.add(a.appt_time__c);
   
    timekl1  = new String[timeset1.size()];
    Integer t = 0;
    for (String state1 : timeset1) { 
      timekl1[t] = state1;
      t++;
      
    } 
    timekl1.sort();
   //stop subhash
   
    // convert the set into a string array  
    rtypes = new String[rtypeset.size()];
    Integer i = 0;
    for (String state : rtypeset) { 
      rtypes[i] = state;
            i++;
    }
    rtypes.sort();
    
    // convert the set into a string array  
   timekl  = new String[timeset.size()];
    Integer j = 0;
    for (String state1 : timeset) { 
      timekl[j] = state1;
      j++;
      
    } 
  
    
   
    
    timekl.sort();
    return null;
   
   }
   //mass cancel the appts by filtered search
 public PageReference cancelled() {
 for(appointment__c app:appointments){
 if(searchText1 != null && app.Check_Out__c !=true && app.Check_In__c !=true){
 app.Cancelled__c = true;
 }
 }
 update appointments;
 return null;
 }
  //mass chk out the appts by filtered search
 public PageReference checkout() {
 for(appointment__c app:appointments){
 if(searchText1 != null && app.Cancelled__c !=true && app.Check_In__c == true){
 app.Check_Out__c = true;
 }
 }
 update appointments;
 return null;
 }
  //mass chk in the appts by filtered search
 public PageReference checkin() {
 
 for(appointment__c app:appointments){
 if(searchText1 != null && app.Cancelled__c !=true){
 app.Check_In__c = true;
  }
  
 }
   
 update appointments;
 

 
 
 
 return null;
 
  }
 
 

how to populate the values of one visual force page to another on a button click

hi all

 

 

i have a visual force page  containing two lookup fields

and two buttons in the page

 

doctor           and                 branch

 

         go      and       go to list

 

apex:commandButton value="GO" action="/apex/calander?br={!appointment__c.branch__c}&dr={!Appointment__c.Doctor__c}&brname={!appointment__c.BRANCH__R.NAME}"/>
<apex:commandButton value="GO to list" action="/apex/Dev_Doctor_Based_Appt?br={!appointment__c.branch__c}&dr={!Appointment__c.Doctor__c}"/> 

 this  code i have written for both the buttons

 

 

now when i press the go to list button i am redirecting to another visual force page that contains the same doctor and branch fields

 

now what should i do to populate my second visual force page with the values of branch and doctor that i have given in my first visual force page

 

 

plz help me in this

 

 

 

 

trigger updatetotalapps on Appointment__c(after update)
{
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps5 {get;set;} 
apps5 = new list<appointment__c>();
apps = new list<appointment__c>();
for(Appointment__c o:Trigger.old )
{   

if (Trigger.isUpdate)
{
appointment__c  app1 =[select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c from appointment__c where id=:o.id];
appointment__c[]  app =[select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c from appointment__c where Appointment__c=:app1.id];
for(appointment__c ap:app)
{
ap.branch__c=app1.branch__c;
ap.Doctor__c=app1.Doctor__c;
ap.Appt_Date__c=app1.Appt_Date__c; 
apps.add(ap);
}
} 
}update apps;
}

 this is the triiger i have written for updating of records but after certain records updaTED ITS THROWING 101 SOQL ERROR PLZ REWRITE MY CODE SO THAT I CAN AVOID THE ERROR

Hi all

  

 

I have a visual force page that consists of two fiels doctor and branch.I also created another visual force page that also contains the same fields branch and doctor .

 

 

now how can i populate my second visual force page with the values given in the first visual force page on a button click

hi all

 

 

I have written a controller for inserting bulk appointments. Actually the objective is i have created an appointment object in which i have two fields FROM and TO. I have taken these fields into another visual force page.Now user goes to that visual force page and enters the from and to timings.For ex:user want bulk appoitments from 1 o clock to 3 then in from field he enters 1 and to field he enters 3. and he will get bulk appointments from 1:00,1:10 1:20 so on upto 2:50. for this i have written the following controller

public class ExtTwo
{
public ExtTwo(ApexPages.StandardController controller) 
{ 
userInputAppointment = new Appointment__c();

}
public Appointment__c userInputAppointment {get; set;}
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps1 {get;set;}  
public list<appointment__c> apps2 {get;set;}
public list<appointment__c> apps3 {get;set;}
public list<appointment__c> apps4 {get;set;}
public list<appointment__c> apps5 {get;set;}

public PageReference save()
{
apps = new list<appointment__c>();
apps1 = new list<appointment__c>();
apps2 = new list<appointment__c>();
apps3 = new list<appointment__c>();
apps4 = new list<appointment__c>();
apps5 = new list<appointment__c>();
integer i=integer.valueof(userInputAppointment.from__c);          
integer i1=integer.valueof(userInputAppointment.To__c);
integer i2=integer.valueof(userInputAppointment.from_min__c);
integer i3=integer.valueof(userInputAppointment.To_Min__c);

if(i<i1)
{ 
for(integer k=0;k<(60-i2)/10;k++)
{
appointment__c ap = new appointment__c();
ap.branch__c =  userInputAppointment.branch__c;
ap.account__c = userInputAppointment.Account__c;
ap.doctor__c=userInputAppointment.doctor__c;
ap.appt_date__c = userInputAppointment.appt_date__c;
ap.Appt_AM_PM__c= 'AM';
if(integer.valueof(userInputAppointment.from__c)>=12)
{
ap.Appt_AM_PM__c= 'PM';
}
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.from__c));
if(integer.valueof(userInputAppointment.from__c)>12)
{
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.from__c)-12);
}
ap.Appt_Minute__c = userInputAppointment.from_min__c;
ap.RecordTypeid=userInputAppointment.RecordTypeid;
if(i2!=integer.valueof(userInputAppointment.from_min__c))
{
ap.RecordTypeid='012N0000000CgSu';
}
apps1.add(ap);
}
insert apps1[0];
and now u see i have declared userinputappointment as a value that is taken from the user . now i have written the test case li8ke this for my controller
@isTest
private class extwoTestclass
{

static testmethod void TestController() 
{
Staff__c s1 = new Staff__c();
      s1.name='Rahul';
      s1.Mobile__c='9849098490';
      insert s1;

Branch__c b = new Branch__c();
b.Name = 'Test';
b.Region__c = 'Market Price';
insert b;

Account a = new Account ();
a.LastName = 'Test';
a.Branch__c = b.id;
a.PersonMobilePhone = '9550412970';
insert a ;

       Appointment__c app = new Appointment__c();
        app.from__c='6';
        app.account__c=a.id;
        app.from_min__c = '00';
        app.Appt_AM_PM__c='PM';
        app.Appt_Date__c=date.ValueOf('2011-05-21');
        app.Appt_Hour__c='9';
        app.Appt_Minute__c='80';
        app.RecordTypeid='012N0000000CgZ2';
        app.Branch__c=b.id;
        app.to_Min__c='40';
        app.to__c='7';       
        insert app;
 
  
  
  
ApexPages.currentPage().getParameters().put('id', app.id);
  

        ApexPages.StandardController con = new ApexPages.StandardController(app); 
       
            ExtTwo cs = new ExtTwo(con);    
        
        pagereference s7 = cs.save();
   
    } 
    
 
}
now i am getting this error system.null pointer expression.Class.ExtTwo.save: line 24, column 27 Class.extwoTestclass.TestController: line 60, column 28 External entry point
now this error indicatres in my controller the userinputappointment.from__c and all fields are taking null values plz help me in writing the test case for my code

 

 

Hi all

 

 

 

I have written a controller that have null fields that user has to enter.In this case wheen i write test  case for my controller i am gettin argument cannot be null.plz help me to write test case in this kind of situatins

hi all
 
i have written a trigger that will update the account owner name on saving a ticket instead of admin name which is by default
 
for ex: if i save a ticket i get admin name generally but i have written a trigger and instead of admin name it updates account owner name now the issue is when i deactivate the account owner it should update the user name for this i have written this trigger







trigger caseAssignWebCaseToAccountOwner on Case (before update) {
for(case c :trigger.new){
user u = [Select id,name,IsActive from user limit 1 ];
if(c.Origin == 'Portal' && c.SSP_owner_Update__c==false && c.accountid!=null && u.isactive == True){
 account a = [select id,name,OwnerId from account where id=:c.accountid];
 c.ownerid=a.ownerID;
 c.SSP_owner_Update__c=true;
}
  if(c.Origin == 'Portal' && u.isactive == False)
  
 c.ownerid= '005Q0000000f95r';

}
}
but now when i deactivate the account owner and save the ticket it is saying

 
Operation with Inactive UserAn operation was performed with an inactive user. 



plz help how to update the ticket name with the user name when we deactivate a account

 

hi all
 
i have written a trigger that will update the account owner name on saving a ticket instead of admin name which is by default
 
for ex: if i save a ticket i get admin name generally but i have written a trigger and instead of admin name it updates account owner name now the issue is when i deactivate the account owner it should update the user name for this i have written this trigger
trigger caseAssignWebCaseToAccountOwner on Case (before update) {
for(case c :trigger.new){
user u = [Select id,name,IsActive from user limit 1 ];
if(c.Origin == 'Portal' && c.SSP_owner_Update__c==false && c.accountid!=null && u.isactive == True){
 account a = [select id,name,OwnerId from account where id=:c.accountid];
 c.ownerid=a.ownerID;
 c.SSP_owner_Update__c=true;
}
  if(c.Origin == 'Portal' && u.isactive == False)
  
 c.ownerid= '005Q0000000f95r';

}
}
but now when i deactivate the account owner and save the ticket it is saying

 
Operation with Inactive UserAn operation was performed with an inactive user. plz help how to update the ticket name with the user login when we deactivate a account

 

hi all

 

i have written a trigger that will update the account owner name on saving a ticket instead of admin name which is by default

 

for ex: if i save a ticket i get admin name generally but i have written a trigger and instead of admin name it updates account owner name now the issue is when i deactivate the account owner it should update the user name for this i have written this trigger

trigger caseAssignWebCaseToAccountOwner on Case (before update) {
for(case c :trigger.new){
user u = [Select id,name,IsActive from user limit 1 ];
if(c.Origin == 'Portal' && c.SSP_owner_Update__c==false && c.accountid!=null && u.isactive == True){
 account a = [select id,name,OwnerId from account where id=:c.accountid];
 c.ownerid=a.ownerID;
 c.SSP_owner_Update__c=true;
}
  if(c.Origin == 'Portal' && u.isactive == False)
  
 c.ownerid= '005Q0000000f95r';

}
}
but now when i deactivate the account owner and save the ticket it is saying


 

Operation with Inactive UserAn operation was performed with an inactive user. plz help how to update the ticket name with the user login when we deactivate a account

plz help me how to cover the else condition in salesforce

hi all 

plz rewrite my code to avoid too many script statements error

public class Dev_From_To_Ctrl
{
public Dev_From_To_Ctrl(ApexPages.StandardController controller) 
{ 
userInputAppointment = new Appointment__c();

}
public Appointment__c userInputAppointment {get; set;}
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps1 {get;set;}  
public list<appointment__c> apps2 {get;set;}
public list<appointment__c> apps3 {get;set;}
public list<appointment__c> apps4 {get;set;}
public list<appointment__c> apps5 {get;set;}
public list<appointment__c>  getall {get;set;}



/*code starts from here
first scenario----from hour less than to hour   ex:8<9 8<15 
sub scenarios in first scenario
ex: from   8:10  to   12:50

scenario 1)8:10 to 8:50
scenario 2)9:00 to 9:50 & 10:00 to 10:50 &11:00 to 11:50
scenario 3)12:00 to   12:50*/




public PageReference save()
{
apps = new list<appointment__c>();
apps1 = new list<appointment__c>();
apps2 = new list<appointment__c>();
apps3 = new list<appointment__c>();
apps4 = new list<appointment__c>();
apps5 = new list<appointment__c>();
string j=userInputAppointment.Appt_24_From_Min__c;
string v =userInputAppointment.Appt_24_To_Min__c;
integer i=integer.valueof(userInputAppointment.Appt_24_From_Hour__c);          
integer i1=integer.valueof(userInputAppointment.Appt_24_To_Hour__c);
integer i2=integer.valueof(userInputAppointment.Appt_24_From_Min__c);
integer i3=integer.valueof(userInputAppointment.Appt_24_To_Min__c);

if(i<i1)
{ 

//scenerio 1 i.e 8:10 to 8:50 stars here
for(integer k=0;k<(60-i2)/10;k++)
{
//first take the given values by user



appointment__c ap = new appointment__c();
ap.Appt_24_From_Hour__c=String.valueOf(i);
ap.Appt_24_To_Hour__c=String.valueOf(i1);
ap.Appt_24_From_Min__c=String.valueOf(j);
ap.Appt_24_To_Min__c=String.valueOf(v);
ap.Dev_Appt_Type_Normal_Or_From_To__c   =true;
ap.branch__c =  userInputAppointment.branch__c;
ap.account__c = userInputAppointment.Account__c;
ap.doctor__c=userInputAppointment.doctor__c;
ap.appt_date__c = userInputAppointment.appt_date__c;
ap.Appt_AM_PM__c= 'AM';
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>=12)
{
ap.Appt_AM_PM__c= 'PM';
}
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>12)
{
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)-12);
}
ap.Appt_Minute__c = userInputAppointment.Appt_24_From_Min__c;
ap.RecordTypeid=userInputAppointment.RecordTypeid;
if(i2!=integer.valueof(userInputAppointment.Appt_24_From_Min__c))
{
//LIVE ID
       // app1.RecordTypeid='01290000000ZXNL';
       
       //SB ID
       ap.RecordTypeid='012N0000000CgZ2';
       
}
apps1.add(ap);
}
insert apps1[0];


// here the first record in the list

userInputAppointment.Appt_24_From_Min__c=String.valueOf(i2);
for(integer k=0;k<(50-i2)/10;k++)
{
appointment__c ap8 = new appointment__c();

ap8.Appt_24_From_Hour__c=String.valueOf(i);
ap8.Appt_24_To_Hour__c=String.valueOf(i1);
ap8.Appt_24_From_Min__c=String.valueOf(j);
ap8.Appt_24_To_Min__c=String.valueOf(v);
ap8.Dev_Appt_Type_Normal_Or_From_To__c   =true;
ap8.branch__c =  userInputAppointment.branch__c;
ap8.account__c = userInputAppointment.Account__c;
ap8.doctor__c=userInputAppointment.doctor__c;
ap8.appt_date__c = userInputAppointment.appt_date__c;
ap8.Appt_AM_PM__c= 'AM';
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>=12)
{
ap8.Appt_AM_PM__c= 'PM';
}
ap8.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>12)
{
ap8.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)-12);
}
ap8.Appt_Minute__c = String.valueOf( integer.valueof(userInputAppointment.Appt_24_From_Min__c)+10);
//LIVE ID
       // app1.RecordTypeid='01290000000ZXNL';
       
       //SB ID
       ap8.RecordTypeid='012N0000000CgZ2';
       
ap8.Dev_Parent_Appt__c=apps1[0].id;
apps4.add(ap8);
userInputAppointment.Appt_24_From_Min__c=String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Min__c)+10);
}
insert apps4;

//scenerio 1 i.e 8:10 to 8:50 ends here


//scenario 2 starts here   i.e  9:00 to 9:50 & 10 to 10:50 &11:00 to 11:50




for( integer l=1;l<i1-i;l++)
{
userInputAppointment.Appt_24_From_Hour__c=String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)+1);
string x='00';
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)<integer.valueof(userInputAppointment.Appt_24_To_Hour__c))
{
for(integer g=0;g<6;g++)
{
appointment__c ap1=new appointment__c();
ap1.Appt_24_From_Hour__c=String.valueOf(i);
ap1.Appt_24_To_Hour__c=String.valueOf(i1);
ap1.Appt_24_From_Min__c=String.valueOf(j);
ap1.Appt_24_To_Min__c=String.valueOf(v);
ap1.Dev_Appt_Type_Normal_Or_From_To__c   =true;
ap1.Appt_24_From_Hour__c=userInputAppointment.Appt_24_From_Hour__c;
ap1.Appt_24_To_Hour__c=userInputAppointment.Appt_24_To_Hour__c;
ap1.Appt_24_From_Min__c=userInputAppointment.Appt_24_From_Min__c;
ap1.Appt_24_To_Min__c=userInputAppointment.Appt_24_To_Min__c;
ap1.branch__c =  userInputAppointment.branch__c;
ap1.account__c = userInputAppointment.Account__c;
ap1.appt_date__c = userInputAppointment.appt_date__c;
ap1.doctor__c=userInputAppointment.doctor__c;
ap1.Appt_AM_PM__c= 'AM';
//LIVE ID
       // app1.RecordTypeid='01290000000ZXNL';
       
       //SB ID
       ap1.RecordTypeid='012N0000000CgZ2';
       
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>=12)
{
ap1.Appt_AM_PM__c= 'PM';
}
ap1.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>12)
{
ap1.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)-12);
}
ap1.Appt_Minute__c=x;
ap1.Dev_Parent_Appt__c=apps1[0].id;
apps2.add(ap1);
x=String.valueOf(integer.valueof(x)+10);
}
}
}
insert apps2;

//scenario 2 ends here   i.e  9:00 to 9:50 & 10 to 10:50 &11:00 to 11:50


//scenario 3  i.e 12:00 to   12:50 stars here






string q='00';


userInputAppointment.Appt_24_From_Hour__c=String.valueOf(i+(i1-i));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)==integer.valueof(userInputAppointment.Appt_24_To_Hour__c))
{
for(integer b=0;b<((i3/10));b++)
{
appointment__c ap3=new appointment__c();
ap3.Appt_24_From_Hour__c=String.valueOf(i);
ap3.Appt_24_To_Hour__c=String.valueOf(i1);
ap3.Appt_24_From_Min__c=String.valueOf(j);
ap3.Appt_24_To_Min__c=String.valueOf(v);
ap3.Dev_Appt_Type_Normal_Or_From_To__c   =true;
ap3.account__c = userInputAppointment.Account__c;
ap3.branch__c =  userInputAppointment.branch__c;
ap3.doctor__c=userInputAppointment.doctor__c;
//LIVE ID
       // app1.RecordTypeid='01290000000ZXNL';
       
       //SB ID
       ap3.RecordTypeid='012N0000000CgZ2';
       
ap3.appt_date__c = userInputAppointment.appt_date__c;
ap3.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c));
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>12)
{
ap3.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)-12);
}
ap3.Appt_AM_PM__c= 'AM';
if(integer.valueof(userInputAppointment.Appt_24_From_Hour__c)>=12)
{
ap3.Appt_AM_PM__c= 'PM';
}
ap3.Dev_Parent_Appt__c=apps1[0].id;
ap3.Appt_Minute__c=q;
ap3.Dev_Parent_Appt__c=apps1[0].id;
apps3.add(ap3);
q=String.valueOf(integer.valueof(q)+10);
}
}  
}
insert apps3;

//scenario 3  i.e 12:00 to   12:50 ends here

 

hi i have wriiten a code which contains 6 insert statements it is working fine for me in sandbox but when we are doing migration its failing and giving too many script statements please help me resolve this issue

plz help me how to write test case for my trigger

trigger Dev_update_Appt on Appointment__c(after update)
{
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps5 {get;set;} 
apps5 = new list<appointment__c>();
apps = new list<appointment__c>();

Map<ID , appointment__c> mapAppiontment = new MAP<ID , appointment__c>([select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c, Dev_Parent_Appt__c from appointment__c where 

id in: trigger.old]);

List<appointment__c> listApp = new List<appointment__c>();

MAP<ID , List<appointment__c>> mapAPPID_List = new MAP<ID , List<appointment__c>>();
for(appointment__c appObj : [select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c,Dev_Parent_Appt__c from appointment__c where   Dev_Parent_Appt__c in: 

mapAppiontment.keyset()])
{
  if(mapAPPID_List.containskey(appObj.Dev_Parent_Appt__c))
     {
         listApp = mapAPPID_List.get(appObj.Dev_Parent_Appt__c);
     }
   else
     {
        listApp = new List<appointment__c>();
     }
  
  listApp.add(appObj);
  mapAPPID_List.put(appObj.Dev_Parent_Appt__c , listApp);

}

for(Appointment__c o:Trigger.old )
{   

if (Trigger.isUpdate)
{
appointment__c  app1 = mapAppiontment.get(o.id);
List<appointment__c>  app  = new List<appointment__c>();

if(mapAPPID_List.containsKey(app1.id))
   app = mapAPPID_List.get(app1.id);

for(appointment__c ap:app)
{
ap.branch__c=app1.branch__c;
ap.Doctor__c=app1.Doctor__c;
ap.Appt_Date__c=app1.Appt_Date__c; 
apps.add(ap);
}
} 
}
update apps;
}

 my test case i have written i am getting 60 percent 

@isTest
private class updateclass
{

static testmethod void TestController() 
{

Staff__c s1 = new Staff__c();
      s1.name='Rahul';
      s1.Mobile__c='9849098490';
      insert s1;


Branch__c b = new Branch__c();
b.Name = 'Test';
b.Region__c = 'Market Price';
insert b;


Account a = new Account ();
a.LastName = 'Test';
a.Branch__c = b.id;
a.PersonMobilePhone = '9550412970';
insert a ;







    Appointment__c app2 = new Appointment__c();
      app2.account__c=a.id;
      
      //app2.Dev_Parent_Appt__c=app1.id;
      
      
         app2.from__c='6';
        
        app2.from_min__c = '00';
        app2.Appt_AM_PM__c='PM';
        app2.Appt_Date__c=date.ValueOf('2011-05-21');
        app2.Appt_Hour__c='9';
        app2.Appt_Minute__c='80';
        app2.RecordTypeid='012N0000000CgZ2';
       
        app2.Branch__c=b.id;
        app2.to_Min__c='40';
        app2.to__c='7';
          insert app2;
       update app2 ;
       
      
       }
       }

 plz help me to resolve my issue

trigger updatetotalapps on Appointment__c(after update)
{
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps5 {get;set;} 
apps5 = new list<appointment__c>();
apps = new list<appointment__c>();
for(Appointment__c o:Trigger.old )
{   

if (Trigger.isUpdate)
{
appointment__c  app1 =[select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c from appointment__c where id=:o.id];
appointment__c[]  app =[select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c from appointment__c where Appointment__c=:app1.id];
for(appointment__c ap:app)
{
ap.branch__c=app1.branch__c;
ap.Doctor__c=app1.Doctor__c;
ap.Appt_Date__c=app1.Appt_Date__c; 
apps.add(ap);
}
} 
}update apps;
}

 this is the triiger i have written for updating of records but after certain records updaTED ITS THROWING 101 SOQL ERROR PLZ REWRITE MY CODE SO THAT I CAN AVOID THE ERROR

Hi all

  

 

I have a visual force page that consists of two fiels doctor and branch.I also created another visual force page that also contains the same fields branch and doctor .

 

 

now how can i populate my second visual force page with the values given in the first visual force page on a button click

hi all

 

 

I have written a controller for inserting bulk appointments. Actually the objective is i have created an appointment object in which i have two fields FROM and TO. I have taken these fields into another visual force page.Now user goes to that visual force page and enters the from and to timings.For ex:user want bulk appoitments from 1 o clock to 3 then in from field he enters 1 and to field he enters 3. and he will get bulk appointments from 1:00,1:10 1:20 so on upto 2:50. for this i have written the following controller

public class ExtTwo
{
public ExtTwo(ApexPages.StandardController controller) 
{ 
userInputAppointment = new Appointment__c();

}
public Appointment__c userInputAppointment {get; set;}
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps1 {get;set;}  
public list<appointment__c> apps2 {get;set;}
public list<appointment__c> apps3 {get;set;}
public list<appointment__c> apps4 {get;set;}
public list<appointment__c> apps5 {get;set;}

public PageReference save()
{
apps = new list<appointment__c>();
apps1 = new list<appointment__c>();
apps2 = new list<appointment__c>();
apps3 = new list<appointment__c>();
apps4 = new list<appointment__c>();
apps5 = new list<appointment__c>();
integer i=integer.valueof(userInputAppointment.from__c);          
integer i1=integer.valueof(userInputAppointment.To__c);
integer i2=integer.valueof(userInputAppointment.from_min__c);
integer i3=integer.valueof(userInputAppointment.To_Min__c);

if(i<i1)
{ 
for(integer k=0;k<(60-i2)/10;k++)
{
appointment__c ap = new appointment__c();
ap.branch__c =  userInputAppointment.branch__c;
ap.account__c = userInputAppointment.Account__c;
ap.doctor__c=userInputAppointment.doctor__c;
ap.appt_date__c = userInputAppointment.appt_date__c;
ap.Appt_AM_PM__c= 'AM';
if(integer.valueof(userInputAppointment.from__c)>=12)
{
ap.Appt_AM_PM__c= 'PM';
}
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.from__c));
if(integer.valueof(userInputAppointment.from__c)>12)
{
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.from__c)-12);
}
ap.Appt_Minute__c = userInputAppointment.from_min__c;
ap.RecordTypeid=userInputAppointment.RecordTypeid;
if(i2!=integer.valueof(userInputAppointment.from_min__c))
{
ap.RecordTypeid='012N0000000CgSu';
}
apps1.add(ap);
}
insert apps1[0];
and now u see i have declared userinputappointment as a value that is taken from the user . now i have written the test case li8ke this for my controller
@isTest
private class extwoTestclass
{

static testmethod void TestController() 
{
Staff__c s1 = new Staff__c();
      s1.name='Rahul';
      s1.Mobile__c='9849098490';
      insert s1;

Branch__c b = new Branch__c();
b.Name = 'Test';
b.Region__c = 'Market Price';
insert b;

Account a = new Account ();
a.LastName = 'Test';
a.Branch__c = b.id;
a.PersonMobilePhone = '9550412970';
insert a ;

       Appointment__c app = new Appointment__c();
        app.from__c='6';
        app.account__c=a.id;
        app.from_min__c = '00';
        app.Appt_AM_PM__c='PM';
        app.Appt_Date__c=date.ValueOf('2011-05-21');
        app.Appt_Hour__c='9';
        app.Appt_Minute__c='80';
        app.RecordTypeid='012N0000000CgZ2';
        app.Branch__c=b.id;
        app.to_Min__c='40';
        app.to__c='7';       
        insert app;
 
  
  
  
ApexPages.currentPage().getParameters().put('id', app.id);
  

        ApexPages.StandardController con = new ApexPages.StandardController(app); 
       
            ExtTwo cs = new ExtTwo(con);    
        
        pagereference s7 = cs.save();
   
    } 
    
 
}
now i am getting this error system.null pointer expression.Class.ExtTwo.save: line 24, column 27 Class.extwoTestclass.TestController: line 60, column 28 External entry point
now this error indicatres in my controller the userinputappointment.from__c and all fields are taking null values plz help me in writing the test case for my code

 

 

Hi all

 

 

 

I have written a controller that have null fields that user has to enter.In this case wheen i write test  case for my controller i am gettin argument cannot be null.plz help me to write test case in this kind of situatins