• krishna3
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 13
    Replies

Hi, 

we have one requirement is that, we need to create profile that profile user cannot able to see the data in the org. but he can able to deploy the code and configuration changes from one evnironment to other.. 

 

any inputs will be more helpful..

 

thanks in advance...

Hi everyone,
I have scenario for that I need to write the trigger.

Here is the scenario.
We have a batch apex on accounts. Currently I am scheduling manually.

We have an object called updates in that we have a field called processed.
Informatica will make that field to true.

Based on that field I need to write the trigger to run the batch apex. Once the batch apex completed update the flag to false.

Can anyone help to write trigger to run the batch apex.

It's urgent...please help me with sample code.

Thanks

Hi everyone,

i have complete the test cass for my Batch apex class. when i was test that code in Developer and Test sandbox its covered 100%. when i deploy that code to QA its show only 27% without any errors.

 

when i check that code DEBUG LOG i got this error....

 

|EXCEPTION_THROWN|[EXTERNAL]|System.UnexpectedException: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.
12:18:21.557|FATAL_ERROR|System.UnexpectedException: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.

 

here is the Batch apex and corresponding test classes.

 

Apex Class:

 

global class ParentContactDefaultDeliverToUpdate implements Database.Batchable<sObject>,Schedulable{

  global String Query;
   
    global ParentContactDefaultDeliverToUpdate(){
     
      Query = 'SELECT Id, otc_contact_id__c, Default_Deliver_To_OTC_Contact_Id__c, Parent_OTC_Contact_Id__c, Needs_Parent_OTC_Contact_Update__c FROM OTC_Contact__c WHERE Needs_Parent_OTC_Contact_Update__C=TRUE';
    }

    global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
    }
     global void execute(SchedulableContext SC){
        ParentContactDefaultDeliverToUpdate obj = new ParentContactDefaultDeliverToUpdate();
        database.executebatch(obj);
        
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope){
    
       Set<String> parentOtcExtIds = new Set<String>(); 
      // Set<String> ddToOtcExtIds = new Set<String>();       
       
       for(sObject s : scope){
           OTC_Contact__c otcCon = (OTC_Contact__c)s;
           if((otcCon.Parent_OTC_Contact_Id__c != NULL)
               || (otcCon.Default_Deliver_To_OTC_Contact_Id__c != NULL) ){
               parentOtcExtIds.add(otcCon.Parent_OTC_Contact_Id__c);
               parentOtcExtIds.add(otcCon.Default_Deliver_To_OTC_Contact_Id__C);
           }
          /* if(otcCon.Default_Deliver_To_OTC_Contact_Id__c != NULL && otcCon.Default_Deliver_To__c == NULL){
               ddToOtcExtIds.add(otcCon.Default_Deliver_To_OTC_Contact_Id__c);
           }*/
       }
       
       List<OTC_Contact__c> OtcContacts = [Select id,Otc_Contact_Id__c from OTC_Contact__c where Otc_Contact_Id__c IN :parentOtcExtIds];
       Map<String,Id> otcContactMap = new Map<String,Id>();
       for(OTC_Contact__c otc : OtcContacts){
           otcContactMap.put(otc.Otc_Contact_Id__c,otc.Id);
       }
       
       for(sObject s : scope){
           OTC_Contact__c otcCon = (OTC_Contact__c)s;
            if(otcCon.Parent_OTC_Contact_Id__c != NULL && otcContactMap.containsKey(otcCon.Parent_OTC_Contact_Id__c)){
                otcCon.Parent_OTC_Contact__c = otcContactMap.get(otcCon.Parent_OTC_Contact_Id__c);
            }
            if(otcCon.Default_Deliver_To_OTC_Contact_Id__c != NULL && otcContactMap.containsKey(otcCon.Default_Deliver_To_OTC_Contact_Id__c )){
                otcCon.Default_Deliver_To__c = otcContactMap.get(otcCon.Default_Deliver_To_OTC_Contact_Id__c );            
            }
          otcCon.Needs_Parent_OTC_Contact_Update__c = FALSE;
          otcCon.Parent_OTC_Contacts_Updated__c = TRUE;  
       }
       update scope;
       
    }
 
    global void finish(Database.BatchableContext BC){
    }
}

 

TEST CLASS:


@isTest

Private class ParentContactDefaultDeliverToUpdate_Test
{
  static testMethod void Testclass(){  

  
   Account acc = new Account(Name = 'Test Name',phone = '53453455435', Customer_Segment__c = 'Bookstore',Account_Status__c = 'Active',
                                    INTG_Physical_Address_Line_1__c = 'Street', 
                                    INTG_Physical_Address_Line_2__c = 'Apt 3',
                                    INTG_Physical_City__c = 'Tarrytown',
                                    INTG_Physical_State_Province_Region__c = 'New York',
                                    INTG_Physical_Country__c = 'USA',
                                   INTG_Physical_Postal_Code__c = '94538'); 
    insert acc; 
    
     Unit__c ut1 = New Unit__c(Name = ' test', Account__c = acc.id);
    
    insert ut1; 
    
    Contact con = new Contact(FirstName = 'Test Name', accountId = acc.id, LastName = 'Test', Phone = '5345345545', Contact_Status__c = 'Active',
                                    INTG_Physical_Address_Line_1__c = 'Street', 
                                    INTG_Physical_Address_Line_2__c = 'Apt 3',
                                    INTG_Physical_City__c = 'Tarrytown',
                                    INTG_Physical_State_Province_Region__c = 'New York',
                                    INTG_Physical_Country__c = 'USA',
                                   INTG_Physical_Postal_Code__c = '94538');     
    insert con;

    OTC_Contact__c otc1 = new OTC_Contact__c(name= 'test', Last_Name__c = 'test', Contact__c = con.id, OTC_Contact_Type__c='AR', 
                                             Otc_Contact_Id__c = '123ARUNISON');
    insert otc1;
    
    OTC_Contact__c otc2 = new OTC_Contact__c(name= 'test', Last_Name__c = 'test', Contact__c = con.id, otc_contact_type__c='SOLDTO',
                                             Otc_Contact_Id__c = '12345SOLDTOUNISON', parent_otc_contact_id__c='123ARUNISON', parent_otc_contact__c=otc1.id, needs_parent_otc_contact_update__c=TRUE);
    insert otc2;
    
    OTC_Contact__c otc3 = new OTC_Contact__c(name='test3', Last_Name__c='test contact', Contact__c= con.id, otc_Contact_type__c='DELIVERTO',
                                               otc_contact_id__c='321DELIVERTOUNISON');
    insert otc3;                                           
    
    OTC_Contact__c otc4 = new OTC_Contact__c (Name = 'Test3', Last_Name__c = 'test3', contact__c = con.id,
                                              Otc_Contact_Id__c='1234SHIPTOUNISON', otc_contact_type__c='SHIPTO', default_deliver_to_otc_contact_id__c='321DELIVERTOUNISON', 
                                              default_deliver_to__c=otc3.id, needs_parent_otc_contact_update__c=TRUE);
    insert otc4;
    
      
    Test.StartTest();  
    
// Schedule the job
        ParentContactDefaultDeliverToUpdate obj1 = new ParentContactDefaultDeliverToUpdate();
      
   //  obj1.query='SELECT Id, otc_contact_id__c, Default_Deliver_To_OTC_Contact_Id__c, Parent_OTC_Contact_Id__c, Needs_Parent_OTC_Contact_Update__C FROM OTC_Contact__c WHERE Needs_Parent_OTC_Contact_Update__C=\' ' + TRUE + '\'  LIMIT=200';
    ID batchprocessid = Database.executeBatch(obj1);
   // OrderTransactionUpdate obj = new OrderTransactionUpdate();
  //  database.executebatch(obj);
  ParentContactDefaultDeliverToUpdate p = new ParentContactDefaultDeliverToUpdate();        
   String sch = '0 0 8 13 2 ?';        
  system.schedule('Schedule Test', sch, p);
  
 Test.stopTest();
       }

 }

 

can anyone help me out with this issue....ITS URGENT

 

thanks in advance....

 

Hi everyone,

 

can anyone help me out how to solve the issue.

 

we have territory management is enable on our environment.

 

when we create Accounts teritory rules will run and the Account will assign to particular user based on the Zipcode we enterted.

 

same need to happen when we edit the record and change the zipcode, but its not happening while editing the records.

 

can this be solve by trigger or apex job??

 

thanks in Advance :smileyhappy:

 

Hi everyone, 

i am trying to update otc Contact records.

i have a field called contact status. when i am trying to update the records with status change, its only updating few reocrds and getting the following error for the other records.

 

 

 execution of AfterUpdate  caused by: System.NullPointerException: Attempt to de-reference a null object  Trigger.UpdatePrimaryUnitOTCContact: line 42, column 30"

 

 

trigger UpdatePrimaryUnitOTCContact on OTC_Contact__c (after insert, after update) {

    List <String> UnitIds= new List<String>();
     For(OTC_Contact__c otc : trigger.new)
     {
       UnitIds.add(otc.Unit__c);
     }
     List<Unit__c>Units = [Select Id, Name, Primary_OTC_Contact__c From Unit__c Where id IN:UnitIds];
     Map<String,Unit__c>UnitMap = New Map<String,Unit__c>(); 
     For(Unit__c ut : Units)
     {
       UnitMap.Put(ut.id, ut);
     }
     Map<id,Unit__c> UnitUpdates = New Map<Id,Unit__c>();
     For(OTC_Contact__c otc : Trigger.new)
     {
       system.debug('Entered for loop');
        if(otc.Is_Primary_Unit_Contact__c==TRUE)
        {
         Unit__c un = UnitMap.get(otc.Unit__c);
                
                system.debug(un.Id);// this is the line i am getting error
                un.Primary_OTC_Contact__c=otc.id;
                UnitUpdates.put(un.id,un);
        }
     }
   update UnitUpdates.values();    
}

 

when i try to comment out that line i am getting an error below the line.

 

can anyone help me out in this..  its urgent 

 

thanks in advance...

hi to everyone,

 

i am converting the lead into account and contact using the vf page, but i am having a problem here,

 

i have 2 fields for street address in both accounts and contacts( line 1 and line 2).

when i convert the lead into accounts and contact i need to split street address field value into line 1 and line 2 in both accounts and contacts.

 

can someone please help me on this issue or some sample code.

 

thanks in advance.

I have been trying to find a fix for the following error.

 

I am recieving the following ereror message when I test an apex class.


System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UpdatePrimaryUnitOTCContact: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.UpdatePrimaryUnitOTCContact: line 29, column 30: []  and 

 

Class.TestupdatePrimaryOTCcontact.testClass: line 14, column 9 External entry point.

 

here is the scenario,

when i am writing test class for UpdatePrimaryOTCContact trigger but i am getting an error in different Trigger(PrimaryUnitOTCContact). 

 

Test Class:


 

@isTest

 

private class TestupdatePrimaryOTCcontact
{
    static testMethod void testClass()
    {  
    
          OTC_Contact__c otc = new OTC_Contact__c();
        otc.Name = '12534585';
        otc.Contact__c = '003Q000000Fqcgx';
        otc.Last_Name__c = 'test';
        otc.Is_Primary__c=TRUE;
        otc.Is_Primary_CheckPoint_Ship_To__c=TRUE;
        otc.Is_Primary_CheckPoint_Learning_Ship_To__c=TRUE;
        Insert otc;
        
        Test.startTest();
        
        Contact ct = ContactInsert();
        ct.Primary_OTC_Contact__c=otc.id;
        ct.Primary_CheckPoint_Ship_To__c=otc.id;
        ct.Primary_CheckPoint_Learning_Ship_To__c=otc.id;        
        update ct;
        
        Test.stopTest();
      }
     public static Contact ContactInsert()
    {
        Contact ct = new Contact();
        ct.LastName = '003Q000000Fqcgx';
        ct.accountid = '001Q000000FJXJY';
        ct.Phone = '1234567890';
        ct.MobilePhone = '5105489586';
        ct.Email= 'alpha@chello.be';
        
         insert ct;
        return ct;
   }
  }

 

 

 

here is the trigger that related to this class:


trigger UpdatePrimaryOTCContact on OTC_Contact__c (after insert, after update) {
    List <String> ContactIds= new List<String>();
     For(OTC_Contact__c otc : trigger.new)
     {
       ContactIds.add(otc.Contact__c);
     }
     List<Contact>Contacts = [Select Id, Name, Primary_OTC_Contact__c, Primary_CheckPoint_Ship_To__c, Primary_Checkpoint_Learning_Ship_To__c From Contact Where id IN:ContactIds];
     Map<String,Contact>ContactMap = New Map<String,Contact>(); 
     For(Contact ct : Contacts)
     {
       ContactMap.Put(ct.id, ct);
     }
     List<Contact> ConUpdates = New List<Contact>();
     For(OTC_Contact__c otc : Trigger.new)
     {
       system.debug('Entered for loop');
        if(otc.Is_Primary__c==TRUE && otc.Is_Primary_Checkpoint_Ship_To__c==TRUE
                        && otc.Is_Primary_Checkpoint_Learning_Ship_To__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_OTC_Contact__c=otc.id;
                con.Primary_CheckPoint_Ship_To__c=otc.id;
                con.Primary_Checkpoint_Learning_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
       else if(otc.Is_Primary__c==TRUE && otc.Is_Primary_Checkpoint_Ship_To__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_OTC_Contact__c=otc.id;
                con.Primary_CheckPoint_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
       else if(otc.Is_Primary_Checkpoint_Ship_To__c==TRUE && otc.Is_Primary_Checkpoint_Learning_Ship_To__c==TRUE)                        
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_CheckPoint_Ship_To__c=otc.id;
                con.Primary_Checkpoint_Learning_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
       else if(otc.Is_Primary__c==TRUE && otc.Is_Primary_Checkpoint_Learning_Ship_To__c==TRUE)
         {
           Contact con = ContactMap.get(otc.Contact__c);
                 
               system.debug(con.Id);
               con.Primary_OTC_Contact__c=otc.id;
               con.Primary_Checkpoint_Learning_Ship_To__c=otc.id;
               ConUpdates.add(con);
         }
     else if(otc.Is_Primary__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_OTC_Contact__c=otc.id;
                ConUpdates.add(con);
         }
     else if(otc.Is_Primary_Checkpoint_Ship_To__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_CheckPoint_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
        else if(otc.Is_Primary_Checkpoint_Learning_Ship_To__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Checkpoint_Learning_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
      }
     
   update ConUpdates; 
   }

 

here is the trigger that i am getting an error saying that De-reference null Object.

 

 

trigger UpdatePrimaryUnitOTCContact on OTC_Contact__c (after insert, after update) {

 

    List <String> UnitIds= new List<String>();

     For(OTC_Contact__c otc : trigger.new)

     {

       UnitIds.add(otc.Unit__c);

     }

     List<Unit__c>Units = [Select Id, Name, Primary_OTC_Contact__c From Unit__c Where id IN:UnitIds];

     Map<String,Unit__c>UnitMap = New Map<String,Unit__c>(); 

     For(Unit__c ut : Units)

     {

       UnitMap.Put(ut.id, ut);

     }

     List<Unit__c> UnitUpdates = New List<Unit__c>();

     For(OTC_Contact__c otc : Trigger.new)

     {

       system.debug('Entered for loop');

        if(otc.Is_Primary_Unit_Contact__c==TRUE)

        {

         Unit__c un = UnitMap.get(otc.Unit__c);

 

                system.debug(un.Id);

                un.Primary_OTC_Contact__c=otc.id;

                UnitUpdates.add(un);

        }

        else

        {

          Unit__c un = UnitMap.get(otc.Unit__c);

 

                system.debug(un.Id);

                un.Primary_OTC_Contact__c=null;

                UnitUpdates.add(un);

        }     

     }

   update UnitUpdates;    

}

 

 

 

can anyone help with sample code for that error. i have to deploy that code into QA tommorow.


thanks in advance and waiting for reply.


I am trying to convert the lead to Account, Contact and Opportunity and there are standard and custom fields required in the convert page.

here i want to use the same standard page and fuctionality and add the additional fields to that page.

 

if it possilble??

if it possible suggest me some code for that.

 

 

thanks,

 

Can the screen used to "Convert Lead" be changed? 
I want to use visual force to modify Lead Convert screen and add all the Fields that are going from Lead to Account and Contact to it. is this possible ?  I am not sure what controller I need to extend.  Please offer your advise and if anyone have code can you please share with me that will be more helpful for me.

Thanks

Hi everyone,

i have complete the test cass for my Batch apex class. when i was test that code in Developer and Test sandbox its covered 100%. when i deploy that code to QA its show only 27% without any errors.

 

when i check that code DEBUG LOG i got this error....

 

|EXCEPTION_THROWN|[EXTERNAL]|System.UnexpectedException: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.
12:18:21.557|FATAL_ERROR|System.UnexpectedException: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.

 

here is the Batch apex and corresponding test classes.

 

Apex Class:

 

global class ParentContactDefaultDeliverToUpdate implements Database.Batchable<sObject>,Schedulable{

  global String Query;
   
    global ParentContactDefaultDeliverToUpdate(){
     
      Query = 'SELECT Id, otc_contact_id__c, Default_Deliver_To_OTC_Contact_Id__c, Parent_OTC_Contact_Id__c, Needs_Parent_OTC_Contact_Update__c FROM OTC_Contact__c WHERE Needs_Parent_OTC_Contact_Update__C=TRUE';
    }

    global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
    }
     global void execute(SchedulableContext SC){
        ParentContactDefaultDeliverToUpdate obj = new ParentContactDefaultDeliverToUpdate();
        database.executebatch(obj);
        
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope){
    
       Set<String> parentOtcExtIds = new Set<String>(); 
      // Set<String> ddToOtcExtIds = new Set<String>();       
       
       for(sObject s : scope){
           OTC_Contact__c otcCon = (OTC_Contact__c)s;
           if((otcCon.Parent_OTC_Contact_Id__c != NULL)
               || (otcCon.Default_Deliver_To_OTC_Contact_Id__c != NULL) ){
               parentOtcExtIds.add(otcCon.Parent_OTC_Contact_Id__c);
               parentOtcExtIds.add(otcCon.Default_Deliver_To_OTC_Contact_Id__C);
           }
          /* if(otcCon.Default_Deliver_To_OTC_Contact_Id__c != NULL && otcCon.Default_Deliver_To__c == NULL){
               ddToOtcExtIds.add(otcCon.Default_Deliver_To_OTC_Contact_Id__c);
           }*/
       }
       
       List<OTC_Contact__c> OtcContacts = [Select id,Otc_Contact_Id__c from OTC_Contact__c where Otc_Contact_Id__c IN :parentOtcExtIds];
       Map<String,Id> otcContactMap = new Map<String,Id>();
       for(OTC_Contact__c otc : OtcContacts){
           otcContactMap.put(otc.Otc_Contact_Id__c,otc.Id);
       }
       
       for(sObject s : scope){
           OTC_Contact__c otcCon = (OTC_Contact__c)s;
            if(otcCon.Parent_OTC_Contact_Id__c != NULL && otcContactMap.containsKey(otcCon.Parent_OTC_Contact_Id__c)){
                otcCon.Parent_OTC_Contact__c = otcContactMap.get(otcCon.Parent_OTC_Contact_Id__c);
            }
            if(otcCon.Default_Deliver_To_OTC_Contact_Id__c != NULL && otcContactMap.containsKey(otcCon.Default_Deliver_To_OTC_Contact_Id__c )){
                otcCon.Default_Deliver_To__c = otcContactMap.get(otcCon.Default_Deliver_To_OTC_Contact_Id__c );            
            }
          otcCon.Needs_Parent_OTC_Contact_Update__c = FALSE;
          otcCon.Parent_OTC_Contacts_Updated__c = TRUE;  
       }
       update scope;
       
    }
 
    global void finish(Database.BatchableContext BC){
    }
}

 

TEST CLASS:


@isTest

Private class ParentContactDefaultDeliverToUpdate_Test
{
  static testMethod void Testclass(){  

  
   Account acc = new Account(Name = 'Test Name',phone = '53453455435', Customer_Segment__c = 'Bookstore',Account_Status__c = 'Active',
                                    INTG_Physical_Address_Line_1__c = 'Street', 
                                    INTG_Physical_Address_Line_2__c = 'Apt 3',
                                    INTG_Physical_City__c = 'Tarrytown',
                                    INTG_Physical_State_Province_Region__c = 'New York',
                                    INTG_Physical_Country__c = 'USA',
                                   INTG_Physical_Postal_Code__c = '94538'); 
    insert acc; 
    
     Unit__c ut1 = New Unit__c(Name = ' test', Account__c = acc.id);
    
    insert ut1; 
    
    Contact con = new Contact(FirstName = 'Test Name', accountId = acc.id, LastName = 'Test', Phone = '5345345545', Contact_Status__c = 'Active',
                                    INTG_Physical_Address_Line_1__c = 'Street', 
                                    INTG_Physical_Address_Line_2__c = 'Apt 3',
                                    INTG_Physical_City__c = 'Tarrytown',
                                    INTG_Physical_State_Province_Region__c = 'New York',
                                    INTG_Physical_Country__c = 'USA',
                                   INTG_Physical_Postal_Code__c = '94538');     
    insert con;

    OTC_Contact__c otc1 = new OTC_Contact__c(name= 'test', Last_Name__c = 'test', Contact__c = con.id, OTC_Contact_Type__c='AR', 
                                             Otc_Contact_Id__c = '123ARUNISON');
    insert otc1;
    
    OTC_Contact__c otc2 = new OTC_Contact__c(name= 'test', Last_Name__c = 'test', Contact__c = con.id, otc_contact_type__c='SOLDTO',
                                             Otc_Contact_Id__c = '12345SOLDTOUNISON', parent_otc_contact_id__c='123ARUNISON', parent_otc_contact__c=otc1.id, needs_parent_otc_contact_update__c=TRUE);
    insert otc2;
    
    OTC_Contact__c otc3 = new OTC_Contact__c(name='test3', Last_Name__c='test contact', Contact__c= con.id, otc_Contact_type__c='DELIVERTO',
                                               otc_contact_id__c='321DELIVERTOUNISON');
    insert otc3;                                           
    
    OTC_Contact__c otc4 = new OTC_Contact__c (Name = 'Test3', Last_Name__c = 'test3', contact__c = con.id,
                                              Otc_Contact_Id__c='1234SHIPTOUNISON', otc_contact_type__c='SHIPTO', default_deliver_to_otc_contact_id__c='321DELIVERTOUNISON', 
                                              default_deliver_to__c=otc3.id, needs_parent_otc_contact_update__c=TRUE);
    insert otc4;
    
      
    Test.StartTest();  
    
// Schedule the job
        ParentContactDefaultDeliverToUpdate obj1 = new ParentContactDefaultDeliverToUpdate();
      
   //  obj1.query='SELECT Id, otc_contact_id__c, Default_Deliver_To_OTC_Contact_Id__c, Parent_OTC_Contact_Id__c, Needs_Parent_OTC_Contact_Update__C FROM OTC_Contact__c WHERE Needs_Parent_OTC_Contact_Update__C=\' ' + TRUE + '\'  LIMIT=200';
    ID batchprocessid = Database.executeBatch(obj1);
   // OrderTransactionUpdate obj = new OrderTransactionUpdate();
  //  database.executebatch(obj);
  ParentContactDefaultDeliverToUpdate p = new ParentContactDefaultDeliverToUpdate();        
   String sch = '0 0 8 13 2 ?';        
  system.schedule('Schedule Test', sch, p);
  
 Test.stopTest();
       }

 }

 

can anyone help me out with this issue....ITS URGENT

 

thanks in advance....

 

Hi everyone,

 

can anyone help me out how to solve the issue.

 

we have territory management is enable on our environment.

 

when we create Accounts teritory rules will run and the Account will assign to particular user based on the Zipcode we enterted.

 

same need to happen when we edit the record and change the zipcode, but its not happening while editing the records.

 

can this be solve by trigger or apex job??

 

thanks in Advance :smileyhappy:

 

hi to everyone,

 

i am converting the lead into account and contact using the vf page, but i am having a problem here,

 

i have 2 fields for street address in both accounts and contacts( line 1 and line 2).

when i convert the lead into accounts and contact i need to split street address field value into line 1 and line 2 in both accounts and contacts.

 

can someone please help me on this issue or some sample code.

 

thanks in advance.

I have been trying to find a fix for the following error.

 

I am recieving the following ereror message when I test an apex class.


System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UpdatePrimaryUnitOTCContact: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.UpdatePrimaryUnitOTCContact: line 29, column 30: []  and 

 

Class.TestupdatePrimaryOTCcontact.testClass: line 14, column 9 External entry point.

 

here is the scenario,

when i am writing test class for UpdatePrimaryOTCContact trigger but i am getting an error in different Trigger(PrimaryUnitOTCContact). 

 

Test Class:


 

@isTest

 

private class TestupdatePrimaryOTCcontact
{
    static testMethod void testClass()
    {  
    
          OTC_Contact__c otc = new OTC_Contact__c();
        otc.Name = '12534585';
        otc.Contact__c = '003Q000000Fqcgx';
        otc.Last_Name__c = 'test';
        otc.Is_Primary__c=TRUE;
        otc.Is_Primary_CheckPoint_Ship_To__c=TRUE;
        otc.Is_Primary_CheckPoint_Learning_Ship_To__c=TRUE;
        Insert otc;
        
        Test.startTest();
        
        Contact ct = ContactInsert();
        ct.Primary_OTC_Contact__c=otc.id;
        ct.Primary_CheckPoint_Ship_To__c=otc.id;
        ct.Primary_CheckPoint_Learning_Ship_To__c=otc.id;        
        update ct;
        
        Test.stopTest();
      }
     public static Contact ContactInsert()
    {
        Contact ct = new Contact();
        ct.LastName = '003Q000000Fqcgx';
        ct.accountid = '001Q000000FJXJY';
        ct.Phone = '1234567890';
        ct.MobilePhone = '5105489586';
        ct.Email= 'alpha@chello.be';
        
         insert ct;
        return ct;
   }
  }

 

 

 

here is the trigger that related to this class:


trigger UpdatePrimaryOTCContact on OTC_Contact__c (after insert, after update) {
    List <String> ContactIds= new List<String>();
     For(OTC_Contact__c otc : trigger.new)
     {
       ContactIds.add(otc.Contact__c);
     }
     List<Contact>Contacts = [Select Id, Name, Primary_OTC_Contact__c, Primary_CheckPoint_Ship_To__c, Primary_Checkpoint_Learning_Ship_To__c From Contact Where id IN:ContactIds];
     Map<String,Contact>ContactMap = New Map<String,Contact>(); 
     For(Contact ct : Contacts)
     {
       ContactMap.Put(ct.id, ct);
     }
     List<Contact> ConUpdates = New List<Contact>();
     For(OTC_Contact__c otc : Trigger.new)
     {
       system.debug('Entered for loop');
        if(otc.Is_Primary__c==TRUE && otc.Is_Primary_Checkpoint_Ship_To__c==TRUE
                        && otc.Is_Primary_Checkpoint_Learning_Ship_To__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_OTC_Contact__c=otc.id;
                con.Primary_CheckPoint_Ship_To__c=otc.id;
                con.Primary_Checkpoint_Learning_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
       else if(otc.Is_Primary__c==TRUE && otc.Is_Primary_Checkpoint_Ship_To__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_OTC_Contact__c=otc.id;
                con.Primary_CheckPoint_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
       else if(otc.Is_Primary_Checkpoint_Ship_To__c==TRUE && otc.Is_Primary_Checkpoint_Learning_Ship_To__c==TRUE)                        
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_CheckPoint_Ship_To__c=otc.id;
                con.Primary_Checkpoint_Learning_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
       else if(otc.Is_Primary__c==TRUE && otc.Is_Primary_Checkpoint_Learning_Ship_To__c==TRUE)
         {
           Contact con = ContactMap.get(otc.Contact__c);
                 
               system.debug(con.Id);
               con.Primary_OTC_Contact__c=otc.id;
               con.Primary_Checkpoint_Learning_Ship_To__c=otc.id;
               ConUpdates.add(con);
         }
     else if(otc.Is_Primary__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_OTC_Contact__c=otc.id;
                ConUpdates.add(con);
         }
     else if(otc.Is_Primary_Checkpoint_Ship_To__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_CheckPoint_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
        else if(otc.Is_Primary_Checkpoint_Learning_Ship_To__c==TRUE)
        {
         Contact con = ContactMap.get(otc.Contact__c);
                
                system.debug(con.Id);
                con.Primary_Checkpoint_Learning_Ship_To__c=otc.id;
                ConUpdates.add(con);
         }
      }
     
   update ConUpdates; 
   }

 

here is the trigger that i am getting an error saying that De-reference null Object.

 

 

trigger UpdatePrimaryUnitOTCContact on OTC_Contact__c (after insert, after update) {

 

    List <String> UnitIds= new List<String>();

     For(OTC_Contact__c otc : trigger.new)

     {

       UnitIds.add(otc.Unit__c);

     }

     List<Unit__c>Units = [Select Id, Name, Primary_OTC_Contact__c From Unit__c Where id IN:UnitIds];

     Map<String,Unit__c>UnitMap = New Map<String,Unit__c>(); 

     For(Unit__c ut : Units)

     {

       UnitMap.Put(ut.id, ut);

     }

     List<Unit__c> UnitUpdates = New List<Unit__c>();

     For(OTC_Contact__c otc : Trigger.new)

     {

       system.debug('Entered for loop');

        if(otc.Is_Primary_Unit_Contact__c==TRUE)

        {

         Unit__c un = UnitMap.get(otc.Unit__c);

 

                system.debug(un.Id);

                un.Primary_OTC_Contact__c=otc.id;

                UnitUpdates.add(un);

        }

        else

        {

          Unit__c un = UnitMap.get(otc.Unit__c);

 

                system.debug(un.Id);

                un.Primary_OTC_Contact__c=null;

                UnitUpdates.add(un);

        }     

     }

   update UnitUpdates;    

}

 

 

 

can anyone help with sample code for that error. i have to deploy that code into QA tommorow.


thanks in advance and waiting for reply.


I am trying to convert the lead to Account, Contact and Opportunity and there are standard and custom fields required in the convert page.

here i want to use the same standard page and fuctionality and add the additional fields to that page.

 

if it possilble??

if it possible suggest me some code for that.

 

 

thanks,

 

Hi All

 

I am trying to convert the lead to opportunity and there are many custom fields required in the convert page. so i written a vf page to include all my custom fields in the page. the issue i am facing is i want the Account to be lookup in the VF page and the convert button is not working with the code i written in the VF page. please have a look at my VF page and the apex class i written for this task. appreciate for all your help

 

VF Page:

 

<apex:page standardController="lead" tabStyle="Lead" extensions="leadController" >
<apex:messages />
<apex:sectionHeader title="Convert Lead"/>
<apex:form >
<apex:pageBlock mode="Edit">
<apex:pagemessages />
<apex:pageBlockSection title="Convert Lead">
         <apex:pageBlockSectionItem >
            <apex:outputLabel value=" Record Owner" for="Record Owner"/>
            <apex:inputField value="{!Lead.OwnerID}"/>
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
           <apex:OutputLabel for="Send Email to the Owner">Send Email to the Owner:</apex:OutputLabel>
           <apex:inputCheckbox onclick=""/>
           </apex:pageBlockSectionItem>            
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Account Name">Account Name</apex:outputLabel>
             <apex:inputField id="Owner" value="{!Lead.Company}" />
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Oppt Name">Opportunity Name:</apex:outputLabel>
             <apex:inputField id="Owner" value="{!Lead.Company}" />
          </apex:pageBlockSectionItem>
          <apex:pageblockSectionItem >
          <apex:outputLabel for="no oppty">Do not create new opportunity upon conversion</apex:outputLabel>
          <apex:inputCheckbox onselect=""/>
          </apex:pageblockSectionItem>
          <apex:pageBlockSectionItem >
                      <apex:outputLabel for="ConStatus">Converted Status:</apex:outputLabel>
             <apex:inputField id="ConStatus" value="{!Lead.Status}" />
          </apex:pageBlockSectionItem>
          </apex:pageBlockSection>         
<apex:pageBlockSection title="Address Information" columns="2" id="AddressInformation">
          <apex:pageBlockSectionItem >
            <apex:outputLabel for="StreetAdd">Street Address:</apex:outputLabel>
          <apex:inputField Id="StreetAdd" Value="{!Lead.Street}" />
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="City">City:</apex:outputLabel>
          <apex:inputField Id="City" Value="{!Lead.City}" />
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="State">State:</apex:outputLabel>
            <apex:inputField Id="State" Value="{!Lead.State}" />
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Zip">Postal Code:</apex:outputLabel>
            <apex:inputField Id="Zip" Value="{!Lead.PostalCode}" />
          </apex:pageBlockSectionItem>                    
          </apex:pageBlockSection>
 <apex:pageBlockSection title="Additional Information" columns="2" id="AdditionalInformation">
          <apex:pageBlockSectionItem >
            <apex:outputLabel for="NoofEmp">No. Of Employees:</apex:outputLabel>
            <apex:inputField Id="Owner" Value="{!Lead.NumberOfEmployees}" />
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Revenue">Annual Revenue:</apex:outputLabel>
                <apex:inputField Id="Revenue" Value="{!Lead.AnnualRevenue}" />      
                      </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Industry">Industry:</apex:outputLabel>
           <apex:inputField Id="Industry" Value="{!Lead.Industry}" />
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Description">Description:</apex:outputLabel>
            <apex:inputField Id="Description" Value="{!Lead.Description}" />
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Website">Website:</apex:outputLabel>
          <apex:inputField Id="Website" Value="{!Lead.Website}" />
          </apex:pageBlockSectionItem>  
          </apex:pageBlockSection>                                   
<apex:pageBlockSection title="Task Information" columns="2" id="TaskInformation">
          
          <apex:pageBlockSectionItem >
            <apex:outputLabel for="Subject">Subject</apex:outputLabel>
            <apex:inputField value="{!Task.Subject}"/>
          </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem >
            <apex:outputLabel for="Status">Status</apex:outputLabel>
            <apex:inputField value="{!Task.Status}"/>
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="DueDate">Due Date</apex:outputLabel>
            <apex:inputField value="{!Task.ActivityDate}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Priority">Priority</apex:outputLabel>
            <apex:inputField value="{!Task.Priority}"/>
          </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem >
            <apex:outputLabel for="EndDate">Completed Date:</apex:outputLabel>
          </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem >
            <apex:outputLabel for="Followupdate">Followup Date:</apex:outputLabel>
          </apex:pageBlockSectionItem>
          </apex:pageBlockSection>      
<apex:pageBlockSection title="Description Information" columns="1" id="DescriptionInformation">
          <apex:pageBlockSectionItem >
            <apex:outputLabel for="Sub">Subject:</apex:outputLabel>
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="Comments">Comments</apex:outputLabel>
            <apex:inputField value="{!Task.Description}"/>
          </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel for="ExtDescription">Extended Description:</apex:outputLabel>
          </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem >
          <apex:OutputLabel for="Send Notification Email">Send Notification Email:</apex:OutputLabel>
           <apex:inputCheckbox onclick=""/>
           </apex:pageBlockSectionItem>
          </apex:pageBlockSection>    
<apex:pageBlockButtons >  
        <apex:commandButton value="Convert"/>
        <apex:commandButton Action="{!Cancel}" value="Cancel"/>
         </apex:pageBlockButtons>                                     
          </apex:pageBlock>  
</apex:form>               
</apex:page>
Class:

 
public class leadController {
        
public leadController(ApexPages.StandardController controller) {
}
public Task getTask(){
    Task tsk = new Task();
    return tsk;
}
    
}

 

Can the screen used to "Convert Lead" be changed? 
I want to use visual force to modify Lead Convert screen and add all the Fields that are going from Lead to Account and Contact to it. is this possible ?  I am not sure what controller I need to extend.  Please offer your advise and if anyone have code can you please share with me that will be more helpful for me.

Thanks

Has anyone has any experience with customizing the lead conversion process? If yes please share. I am trying to achieve this.

 

But the fields for ConvertedAccountId, ConvertedOpportunityId, ConvertedContactId are not updatable on the Lead record. I was hoping that I could update this with the corresponding converted record ids, so that if the Lead is clicked on post conversion, we would get the usual page saying this lead was converted into xyz Acct, Contact & Oppty. I can create lookup fields to these 3 obj on the Lead, populate them and change the rec type and the page layout using a Workflow rule. But the problem would still exist if someone reports on converted leads using the standard 'Converted' reporting field.

 

If anyone has had experiences with custom lead conversion, please share. 

Message Edited by niksss on 11-04-2009 07:45 PM
  • November 05, 2009
  • Like
  • 0