• sdfasd
  • NEWBIE
  • 50 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 17
    Replies

i created  field in Opportunity object    i.e Renewal Date.

 

once Product is added  to Particual Opportunity record  then automatically updated Renewal Date with Today Date .using workflow. please help me.......................................

  • February 10, 2012
  • Like
  • 0

how to automatically added the products(opportunity lineitem) based on condtion.

in Opporutnity i created 2Fields i.e

                                                                1.ServiceType (Picklist datatype   Required)

                                                                2.ContractLengthmonth(Text datatype Required).

 

1.ServiceType picklist contain National,International,NotProvider values

 

i created some products in product object. like international service 01months , International Service 03months and International Service 06 month. each product contain pricebooks.

 

Now i fills the Opportunity information in opporutnity that time i select the International value from ServiceType picklist  and  i fills  the 3 in ContractLengthmonth Field. after i click on save button  then automatically added the Prodcut details  i.e  Internation Service 03months like this. 

 

samelike i select the International value from ServiceType picklist and i fills the 2 in ContractLengthmonth field after i click on save button then automatically  added the product details. i.e International Service 02months product name. how can create the trigger for this task please help me...............................


  • February 02, 2012
  • Like
  • 0

how to automatically add the product details to each opportunity using trigger  . pls help me

  • January 31, 2012
  • Like
  • 0

i  created trigger for Lead Conversion. i created two cusotm obejcts i.e  Agency and Broker custom objects.

1. once lead is converted lead company name goes to Agency  and lead name goes to broker object..

2. once lead is converted Salesforce automatically created account and contact records.But i want no need to created account and contact records once lead is converted. i want delete the account and contact records.

how can solve this problem. i write the trigger for lead conversion to agency and broker objects that's workng fine but account and contact records not deleted. pls help me..................................

Trigger

======

trigger ConvertLead on Lead (after update) {
    
    List<Lead> leadIds = new List<Lead>();
    List<ID> LIds = new List<ID>();
    List<ID> accountIds= new List<ID>();
    List<ID> cids = new List<ID> {};
    List<Account> aclist = new List<Account> {};
    List<Contact> contactids = new List<Contact>();
    List<Task> tasklist = new List<Task> {};
    Id lId;
    
    List<RecordType> rtypes = [Select Name, Id From RecordType where sObjectType='Lead' and isActive=true];
    Map<String,String> leadRecordTypes = new Map<String,String>{};
    
    for(RecordType rt: rtypes){
        leadRecordTypes.put(rt.Name,rt.Id);
    }
       
    for(Lead led: Trigger.New){
        System.debug('Lead Details:'+led);
         if(led.isConverted == true && led.Lead_type_picklist__c =='Broker'&& led.RecordTypeId==leadRecordTypes.get('Broker')){
       // if(led.isConverted == true && led.RecordTypeId =='012G0000000GNaJIAW'){
            leadIds.add(led);
            LIds.add(led.Id);
            accountIds.add(led.ConvertedAccountId);
        }
    }
    
    for(Account ac: [select id from account where id in : accountIds]) {
        //ac.RecordTypeId = '012Z00000004KO6';
        aclist.add(ac);
    }
     

    Map<Id,Lead> leadMap = new Map<Id,Lead>([Select id,Name,Company,LeadSource,Street,City,State,County__c,PostalCode,Website,Title,Email,Phone  from Lead Where id in:LIds]);
    List<Agency__c > agencyinsert = new List<Agency__c >();
    List<Broker__c> brokers = new List<Broker__c>();
    
    for(integer i=0; i<leadIds.size(); i++){
        lId = leadIds[i].Id;
        Lead leadobj = leadMap.get(lId);
        Agency__c ag = new Agency__c();
        ag.Name = leadobj.Company;
        ag.Mailing_Address__c =leadobj.Street;
        ag.City__c =leadobj.City;
        ag.State__c = leadobj.State;
        ag.County__c = leadobj.County__c;
        ag.Zip_Code__c = leadobj.PostalCode;  
        ag.Phone__c = leadobj.Phone;
        ag.Website__c = leadobj.Website;
        agencyinsert.add(ag);
    }
    if( agencyinsert.size()>0)
        insert agencyinsert;
 
   for(integer i=0; i<leadIds.size(); i++){
      for(integer j=0; j<agencyinsert.size(); j++){
             Lead leadobj1 = leadMap.get(lId);
             Broker__c b = new Broker__c();
             b.Name = leadobj1.Name;
             b.Agency__c = agencyinsert[j].id;
             b.Title__c = leadobj1.Title;
             b.Address__c = leadobj1.Street;
             b.City__c  = leadobj1.City;
             b.State__c = leadobj1.State;
             b.County__c = leadobj1.County__c;
             b.Zip_Code__c = leadobj1.PostalCode;
             b.Phone__c = leadobj1.Phone;
             b.Email__c = leadobj1.Email;
             b.Website__c = leadobj1.Website;
             b.Broker_Appointment_Lead_Source__c  = leadobj1.LeadSource;
             brokers.add(b);
         
      }
   }
    if(brokers.size() > 0)
        insert brokers;
    
    if(aclist.size()>0)
       delete aclist;
   }

  • January 27, 2012
  • Like
  • 0

i created LeadGrid Visualforce page .after i created site i add the LeadGrid visualforce page in this site.after i click on URL  Lead Grid page details displayed in site but Fields and data will not showing this is the problem. how can solve this problem.

 

i want to display the all columns heards and data of lead in site . pls help me.......................

  • January 27, 2012
  • Like
  • 0

i created BulkTrigger for Lead Conversion.i created two custom objects. i.e   Agency and Broker objects.

i. Now Lead is Converted then  Lead company name goes to Agency and Lead Name goes to Broker object. that's working fine.

ii. once lead is converted Salesforce automatically created account and contact records.But we Need to Prevent the Account and Contact inserting. .is it possiable. ...............Pls Help me...........................

 

User Manually Lead Records converted using Convert Button in Lead home page.

 

MyTrigger

===========

trigger ConvertLead on Lead (after insert, after update) {
    
    List<Lead> leadIds = new List<Lead>();
    Id lId;
  for(Lead led: Trigger.New){
        if(led.isConverted == true && led.Lead_type_picklist__c =='Broker'){
            if(led.id != null)
               leadIds.add(led);
        }
    }
    Map<Id,Lead> leadMap = new Map<Id,Lead>([Select id,Name,Company from Lead Where id in:leadIds]);
    List<Agency__c > agencyinsert = new List<Agency__c >();
    List<Broker__c> brokers = new List<Broker__c>();
    
    for(integer i=0; i<leadIds.size(); i++){
        lId = leadIds[i].Id;
        Lead leadobj = leadMap.get(lId);
        Agency__c ag = new Agency__c();
       agencyinsert.add(ag);
    }
    if( agencyinsert.size()>0)
        insert agencyinsert;
 
   for(integer i=0; i<leadIds.size(); i++){
      for(integer j=0; j<agencyinsert.size(); j++){
             Lead leadobj1 = leadMap.get(lId);
             Broker__c b = new Broker__c();
             b.Name = leadobj1.Name;
             b.Agency__c = agencyinsert[j].id;
             brokers.add(b);
         }
    }
     if(brokers.size() > 0)
        insert brokers;
}

 

How can Prevent the inserting account and contact records once lead is conversion.pls help me...............................

  • January 24, 2012
  • Like
  • 0

i created Trigger for Lead. once lead is converted automatically account,contact,opportunity is created.i created two custom objects.i.e agency and broker objects.

i. once lead is converted then company name goes to account then agency is created based on accountname.

ii.once lead is converted then  LeadName goes to Contact then Broker is Created based on contact name.

i created bulktrigger for this  condtions.

But now i need  once lead is converted directly we created agency and brokers records based on lead company name and lead name .how can solve this problem.pls help me........................

  • January 24, 2012
  • Like
  • 0

i Create the trigger for lead conversion . now i need test codecoverage for Lead Conversion Trigger. how to create the test class for this trigger.pls help me................

 

Trigger

======

trigger ConvertLead on Lead (after insert, after update) {
    
    List<Id> accountIds = new List<Id>();
    List<Id> contactIds = new List<Id>();
    list<lead> leadobject = new List<lead>();
    
    List<RecordType> rtypes = [Select Name, Id From RecordType where sObjectType='Lead' and isActive=true];
    Map<String,String> leadRecordTypes = new Map<String,String>{};
    
    for(RecordType rt: rtypes){
        leadRecordTypes.put(rt.Name,rt.Id);
    }
    
    for(Lead led: Trigger.New){
        if(led.isConverted == true && led.Lead_type_picklist__c =='Broker' && led.RecordTypeId==leadRecordTypes.get('Broker')){
            if(led.ConvertedAccountId != null && led.ConvertedContactId != null )
               leadobject.add(led);
               accountIds.add(led.ConvertedAccountId);
               contactIds.add(led.ConvertedContactId);
        }
    }
    
    Map<Id,Account> accountMap = new Map<Id,Account>([Select Id,Name,BillingStreet,BillingCity,BillingState,County__c,BillingPostalCode,Phone from Account where Id IN: accountIds]);
    Map<Id,contact> contactMap = new Map<Id,contact>([Select Id,Name,Accountid from contact where Id IN: contactIds]);
    List<Agency__c > agencyinsert = new List<Agency__c >();
    List<Broker__c> brokers = new List<Broker__c>();
    
    for(integer i=0; i<leadobject.size(); i++){
        Id accId = leadobject[i].ConvertedAccountId;
        Id cId = leadobject[i].ConvertedContactId;
        Account accountobj = accountMap.get(accId);
        Contact contactobj = contactMap.get(cId);
        
        Agency__c ag = new Agency__c();
        ag.Name = accountobj.Name;
        ag.Mailing_Address__c = accountobj.BillingStreet;
        ag.City__c =accountobj.BillingCity;
        ag.State__c = accountobj.BillingState;
        ag.County__c = accountobj.County__c;
        ag.Zip_Code__c = accountobj.BillingPostalCode;  
        ag.Account__c = accountobj.Id;
        ag.Phone__c = accountobj.Phone;
        agencyinsert.add(ag);
    }
    if( agencyinsert.size()>0)
        insert agencyinsert;
 
  for(integer i=0; i<leadobject.size(); i++){
     for(integer j=0; j<agencyinsert.size(); j++){
         if(leadobject[i].ConvertedAccountId == agencyinsert[j].Account__c){
            Id cId = leadobject[i].ConvertedContactId;
            Contact contactobj = contactMap.get(cId);
            Broker__c b = new Broker__c();
            b.Name = contactobj.Name;
            b.Agency__c = agencyinsert[j].id;
            b.Contact_ID__c = contactobj.Id;
            brokers.add(b);
         }
     }
  }
 
}

 

pls help.................

  • January 23, 2012
  • Like
  • 0

Thanks your Post Rajiv .i am using your code but this code not saved display the Errors.

 

 i.e  Initial term of field expression must be a concrete SObject: LIST<Lead> at line 20 column 12

 

Trigger

======

trigger ConvertLead on Lead (after insert, after update) {

List<Id> accountIds = new List<Id>();
List<Id> contactIds = new List<Id>();
list<lead> leadobject = new List<lead>();

for(Lead led: Trigger.New){
if(led.isConverted == true && led.Lead_type_picklist__c =='Broker'){
if(led.ConvertedAccountId != null && led.ConvertedContactId != null )
leadobject.add(led);
accountIds.add(led.ConvertedAccountId);
contactIds.add(led.ConvertedContactId);
}
}
Map<Id,Account> accountMap = new Map<Id,Account>([Select Id from Account where Id IN: accountIds]);
Map<Id,contact> contactMap = new Map<Id,contact>([Select Id from contact where Id IN: contactIds]);
List<account> accountinsert = new List<Account>();
List<Broker__c> brokers = new List<Broker__c>();
for(integer i=0; i<leadobject.size(); i++){
Id accId = leadobject.ConvertedAccountId; //at line 20 column 12 ERROR LINE
Id cId = leadobject.ConvertedContactId;   //at line 20 column 12    ERROR LINE
Account accountobj = accountMap.get(accId);
Contact contactobj = contactMap.get(cId);
Agency__c ag = new Agency__c();
ag.Name = accountobj.Name;
ag.Mailing_Address__c = accountobj.BillingStreet;
ag.City__c =accountobj.BillingCity;
ag.State__c = accountobj.BillingState;
ag.County__c = accountobj.County__c;
ag.Zip_Code__c = accountobj.BillingPostalCode;
ag.Account__c = accountobj.ConvertedAccountId;
ag.Phone__c = accountobj.Phone;
accountinsert.add(ag);
Broker__c b = new Broker__c();
b.Name = contactobj.Name;
b.Agency__c = accountobj.id;
b.Contact_ID__c = contactobj.Id;
brokers.add(b);
}
if( accountinsert.size()>0)
insert accountinsert;
if(brokers.size() > 0)
insert brokers;
}

 

how can solve this problem pls help me....................

  • January 23, 2012
  • Like
  • 0

i Created the Trigger for Lead Conversion to Custom object. Now i Need BulkTrigger for Lead Conversion. i can try but still i am not completed how to  create the BulkTrigger. in this Trigger i am using Two custom objects.i.e Agency and Broker once Lead is converted Lead Name goes to Broker and Company goes to Agency object.This code working fine but this not Bulk Process. i need BulkProcess for this Trigger.Please help me.................

Trigger

=======

trigger ConvertLead on Lead (after insert, after update) {

 

if (Trigger.new.size()> 0){

if(Trigger.new[0].isConverted == true && Trigger.new[0].Lead_type_picklist__c =='Broker') {
   

   if (Trigger.new[0].ConvertedAccountId != null){

for(Account a :[Select a.Id,a.Name,a.Description,a.BillingStreet,a.BillingState, a.BillingPostalCode, a.BillingCountry, a.BillingCity,a.county__c,a.phone From Account a Where a.Id =:Trigger.new[0].ConvertedAccountId]){
ag = new Agency__c();
ag.Name = a.Name;
ag.Mailing_Address__c = a.BillingStreet;
ag.City__c =a.BillingCity;
ag.State__c = a.BillingState;
ag.County__c = a.County__c;
ag.Zip_Code__c = a.BillingPostalCode;
ag.Account__c = Trigger.new[0].ConvertedAccountId;
ag.Phone__c = a.Phone;
}
insert ag;
}
List<Contact> con = new List<Contact>();
List<Broker__c> brokers = new List<Broker__c>();

if(Trigger.new[0].ConvertedContactId != null){

for(Contact c :[Select id,Name,Description,AccountId from Contact where Id = :Trigger.new[0].ConvertedContactId]){
Broker__c b = new Broker__c();
b.Name = c.Name;
b.Agency__c = ag.id;
b.Contact_ID__c = c.Id;
brokers.add(b);
}
insert brokers;
}
}
}
}

how can i created BulkProcess for this Trigger pls help................

  • January 23, 2012
  • Like
  • 0

i got new requirement from my client.  i created two custom objects i.e  Agency and Broker objects.

                  i.  Agency object is Master to Broker object.

                 ii. created Account lookup field in Agency object..

Task is  once Lead is  Converted then  company name goes to Agency object and FirstName and LastName goes to Broker object. this is the Task . I Created Trigger for this task. Comapany name goes to Agency object working properly but Broker object have Agency Requiredfield how can i get the Agency id  in Broker object.

 

My Trigger :

==========

trigger ConvertLead on Lead (after insert, after update) {
 
 if(Trigger.new.size() >0) {
    
    if(Trigger.new[0].isConverted == true && Trigger.new[0].Lead_type_picklist__c =='Broker') {
       
       List<Agency__c> agency = new List<Agency__c>();
       List<Account> acc = new List<Account>();
       List<Lead> lead = new List<Lead>();
       List<ID>   LIDs = new List<ID>();
       
       for(Lead l:Trigger.New){
           lead.add(l);
           LIDs.add(l.id);
       }
     
       if(Trigger.new[0].ConvertedAccountId != null){
          
          for(Account a :[Select a.Id,a.Name,a.Description,a.BillingStreet,a.BillingState, a.BillingPostalCode, a.BillingCountry, a.BillingCity  From Account a Where a.Id =:Trigger.new[0].ConvertedAccountId]){
              a.Description= Trigger.new[0].Name;
              acc.add(a);
              Agency__c ag = new Agency__c();
              ag.Name = a.Name;
              ag.Mailing_Address__c = a.BillingStreet;
              ag.City__c =a.BillingCity;
              ag.State__c = a.BillingState;
              ag.County__c = a.County__c;
              ag.Zip_Code__c = a.BillingPostalCode;
              ag.Account__c = Trigger.new[0].ConvertedAccountId;
              ag.Phone__c = a.Phone;
              agency .add(ag);
            }
             update acc;
             insert agency;
       }
        
           List<Contact> con = new List<Contact>();
           List<Broker__c>  brokers = new List<Broker__c>();
       
       if(Trigger.new[0].ConvertedContactId != null ) {
           for(Contact c :[Select id,Name,Description,AccountId  from Contact where  Id = :Trigger.new[0].ConvertedContactId]){
               c.Description = Trigger.new[0].Name;
               con.add(c);
             
               Broker__c  b = new Broker__c();
               b.Name = c.Name;
               b.Agency__c =
               b.Contact_ID__c = c.Id;
               brokers.add(b);
           }
              update con;
              insert brokers;
         }
       }
     }
   }

 

now i need Agency id how can solve this problem .Please help ...............      

  • January 19, 2012
  • Like
  • 0

i got new requirement from my client i know how to create the Pagelayouts for standarda and custom object. but how to create the pagelayouts From  Template.how can solve this one.pls help me

  • January 19, 2012
  • Like
  • 0

1. i created the Trigger. Trigger use is once insert the records in Broker object automatically convert the records in contact object. once update the Broker object then Contact also updated.once delete the Broker object Contact also deleted.Trigger working Properly. but i need the Test Class for this Trigger. Test class code coverage is 13% how can i reach 75%. please help me .................

 

Trigger:

=====

 if(Trigger.isInsert){
        List<Contact> con = new List<Contact>();
        List<Broker__c> bro = new List<Broker__c>();
        List<Broker__c> UBList = new List<Broker__c>();
        List<ID> BIDs = new List<ID> {};
        for(Broker__c br:Trigger.New){
            bro.add(br);
            BIDs.add(br.id);
        }
      
        for(Broker__c b: bro) {
            Contact c = new Contact();
            c.LastName = b.Name;
            c.Title=b.Title__c;
            c.Contact_type__c=b.Broker_Type__c;
            c.Appointed_w_SeeChange__c=b.Appointed_with_SeeChange__c;
            c.RecordTypeId='012Z00000004JZS';
            c.Broker__c = b.Id;
           
            con.add(c);
        }
        insert con;
        
       Map<ID,Broker__c> UB = new Map<ID,Broker__c> {};
         for(Broker__c bc: [select id, contact_id__c, Agency__r.OwnerId from Broker__c where Id in : BIDs]) {
                UB.put(bc.Id,bc);
        }
        
        for(Contact c: con) {
            if(UB.containsKey(c.Broker__c)) {
                Broker__c UBCon = UB.get(c.Broker__c);
                UBCon.Contact_ID__c = c.Id;
                UBCon.Owner__c = UBCon.Agency__r.OwnerId;
                UBList.add(UBCon);
            }
        }
        update UBList;

    }    
    //Update Contact        
    if(Trigger.isUpdate){
        Map<ID,Broker__c> UB1 = new Map<ID,Broker__c> {};
        List<Contact> UpConList = new List<Contact> {};
        Set<ID> UBIDs = new Set<ID> {};
        for(Broker__c b: Trigger.new) {
            UB1.put(b.id,b);            
            UBIDs.add(b.id);
        }
        
        System.debug('Broker Map:'+UB1);
        for(Contact c: [select id, broker__c from contact where broker__c in :UBIDs]){
            Broker__c b = new Broker__c();
            if(UB1.containsKey(c.broker__c)) {
                b = UB1.get(c.broker__c);
                System.debug('Map get:'+b);
                c.LastName = b.Name;
                c.Title=b.Title__c;
                c.Contact_type__c=b.Broker_Type__c;
                c.Appointed_w_SeeChange__c=b.Appointed_with_SeeChange__c;
                c.Appointed_since__c=b.Appointed_Since__c;
                c.RecordTypeId='012Z00000004JZS';
                c.Broker__c = b.Id;
                UpConList.add(c);
            }
        }
        System.debug('UpConList:'+UpConList);
        update UpConList;
     }
     
    //Delete Contact
    if(Trigger.isDelete){
        List<ID> DBList = new List<ID>();
        List<Contact> DelConList = new List<Contact>();
        for(Broker__c b:Trigger.old) {
            DBList.add(b.id);
            System.debug('b value:'+b+'b.id:'+b.id);
        }  
        
        System.debug('DBList:'+DBList);
        DelConList = [select id from contact where Broker__c in :DBList];
        if(DelConList.size() >0) {
           delete DelConList;
        }
    }
 

i write the test class for Trigger. but showing this error Exception:System.ListException: Duplicate id in list:

 

how can solve this problem........

 

  • January 10, 2012
  • Like
  • 0

how to convert the datetime field to salesforce datetime like 'yyyy-MM-dd\'T\'hh:mm:ss\'Z\''. this format i am write code like this.

       DateFormat BSD;

        DateFormat BSD = new SimpleDateFormat('yyyy-MM-dd\'T\'hh:mm:ss\'Z\'');                               
        BSD.setTimeZone(TimeZone.getTimeZone('GMT'));

 

 

i need  DateTime  yyyy-MM-dd\'T\'hh:mm:ss\'Z\''   this  formate pls help me.........

 

  • January 07, 2012
  • Like
  • 0

i need to send a Billions of emails to contact using Batch Apex .i am New in Salesforce Apex . how can do this Batch Apex for MassEmail to Contact. please help me .......................

  • January 06, 2012
  • Like
  • 0

i need to send a Billions of emails to contact using Batch Apex .i am New in Salesforce Apex . how can do this Batch Apex for MassEmail to Contact. please help me .......................

  • January 06, 2012
  • Like
  • 0

i created value "Founded" in Opportunity Stage field. and i created 10 custom  Fields (Datatype= Currency) in Opportunity.

 

1. i Fills  each Currency field value is "0" total 10 currency fields values "0" and i select the Founded value from StageName field. Now i need  display the validation error message. i.e Total Currency Field values  must be > 0.

 

i write code like this

 

AND(ISPICKVAL(StageName,"Founded"),

Building__c +
Land__c +
Tenant_Improvements__c +
Ground_up_construction__c +
Addition_to_building__c +
Renovations__c +
Leasehold_Improvements__c +
Equipment__c +
Furniture_Fixtures__c +
Refinanced_Debt__c +
Other_Expenses__c +
Professional_Fees__c > 0))

 

please help me how can solve this problem...............

 


  • January 05, 2012
  • Like
  • 0

i create the trigger for convert the records from account obejct to contact object. condition is

 if(a1.Group_Admin_Name__c != null ){

}

 

1.account object  contain Group_Admin_Name__c field. once fils the records in account object that time fills the value in GroupAdminName field. then converted records from account to contact. but records displayed in contact object two times.this is the problem

2.i created update trigger also.once edit the account record then fills the GroupAdminName click on save buttn records will be converted to contact object.this one working properly.

 

Trigger:

======

 

trigger ConvertQualifiedCasetoContact on Account (after insert, after update) {
    
   if(Trigger.isInsert){
      List<Account> acc = new List<Account>();
      List<Contact> con = new List<Contact>();
      List<ID> AID = new List<ID>();
   
   for(Account ac:Trigger.New){
       acc.add(ac);
       AID.add(ac.id);
   }
   for(Account a:acc) {
       Contact c = new Contact();
       if(a.Group_Admin_Name__c != null){
          c.LastName = a.Group_Admin_Name__c;
          c.Email = a.Group_Admin_Email__c;
          c.Phone = a.Group_Admin_Phone__c;
          c.AccountId = a.ID;
          con.add(c);
         }
       }
       insert con;
   }
   
    if(Trigger.isUpdate){
       List<Account> acc = new List<Account>();
       List<Contact> con1 = new List<Contact>();
       set<ID> aid = new set<ID>();
       for(Account ac:Trigger.old){
           acc.add(ac);
           aid.add(ac.id);
       }
       
     for(Account a:acc){
         Account a1 = [Select id,Group_Admin_Name__c,Group_Admin_Email__c,Group_Admin_Phone__c   from Account where id in :aid];
         Contact c = new Contact();
         if(a1.Group_Admin_Name__c != null ){
            c.LastName = a1.Group_Admin_Name__c;
            c.Email = a1.Group_Admin_Email__c;
            c.Phone = a1.Group_Admin_Phone__c;
            c.AccountId = a.ID;
            con1.add(c);
           }
        }
        update con1;
    }
 }

 

pls help me.........

  • January 03, 2012
  • Like
  • 0

1. i created one custom object i.e  Broker__c.

2. in Contact object i created one lookup field to Broker__c object(Field Name : Broker__c(lookup))

3.i created trigger for  once inser the records in Broker object. that record convert to Contact object. and once i update the Broker object record then Contact object record also updated based on Broker id.

 

4. Now my requirement is i delete the Broker object record then Contact object record also deleted based on Broker id using trigger.i write code for delete the records.but records is not deleted this is my problem. pls help me......

 

Delete Trigger

================

 

 

if(Trigger.isDelete){
        List<ID> DBList = new List<ID>();
        System.debug('DBList:'+DBList);
        for(Broker__c b:Trigger.old) {
            DBList.add(b.id);
        }
        
       for( List<Contact> DelConList :[select id from contact where Broker__c in :DBList]){
        if(DelConList.size() >0) {
           System.debug('DelConList:'+DelConList);
           delete DelConList;
        }
    }

  • January 02, 2012
  • Like
  • 0

i created Apex class ,component and visualforce page for  download the Case objects records into CSV file. now downloaded case object records into CSV file  But All the column headers displayed in csv file 2Row . i need to display the column headers First Row. how can solve this problem please any one help me...............

 

 

  • December 21, 2011
  • Like
  • 0

how to automatically added the products(opportunity lineitem) based on condtion.

in Opporutnity i created 2Fields i.e

                                                                1.ServiceType (Picklist datatype   Required)

                                                                2.ContractLengthmonth(Text datatype Required).

 

1.ServiceType picklist contain National,International,NotProvider values

 

i created some products in product object. like international service 01months , International Service 03months and International Service 06 month. each product contain pricebooks.

 

Now i fills the Opportunity information in opporutnity that time i select the International value from ServiceType picklist  and  i fills  the 3 in ContractLengthmonth Field. after i click on save button  then automatically added the Prodcut details  i.e  Internation Service 03months like this. 

 

samelike i select the International value from ServiceType picklist and i fills the 2 in ContractLengthmonth field after i click on save button then automatically  added the product details. i.e International Service 02months product name. how can create the trigger for this task please help me...............................


  • February 02, 2012
  • Like
  • 0

how to automatically add the product details to each opportunity using trigger  . pls help me

  • January 31, 2012
  • Like
  • 0

i created LeadGrid Visualforce page .after i created site i add the LeadGrid visualforce page in this site.after i click on URL  Lead Grid page details displayed in site but Fields and data will not showing this is the problem. how can solve this problem.

 

i want to display the all columns heards and data of lead in site . pls help me.......................

  • January 27, 2012
  • Like
  • 0

i created Trigger for Lead. once lead is converted automatically account,contact,opportunity is created.i created two custom objects.i.e agency and broker objects.

i. once lead is converted then company name goes to account then agency is created based on accountname.

ii.once lead is converted then  LeadName goes to Contact then Broker is Created based on contact name.

i created bulktrigger for this  condtions.

But now i need  once lead is converted directly we created agency and brokers records based on lead company name and lead name .how can solve this problem.pls help me........................

  • January 24, 2012
  • Like
  • 0

Thanks your Post Rajiv .i am using your code but this code not saved display the Errors.

 

 i.e  Initial term of field expression must be a concrete SObject: LIST<Lead> at line 20 column 12

 

Trigger

======

trigger ConvertLead on Lead (after insert, after update) {

List<Id> accountIds = new List<Id>();
List<Id> contactIds = new List<Id>();
list<lead> leadobject = new List<lead>();

for(Lead led: Trigger.New){
if(led.isConverted == true && led.Lead_type_picklist__c =='Broker'){
if(led.ConvertedAccountId != null && led.ConvertedContactId != null )
leadobject.add(led);
accountIds.add(led.ConvertedAccountId);
contactIds.add(led.ConvertedContactId);
}
}
Map<Id,Account> accountMap = new Map<Id,Account>([Select Id from Account where Id IN: accountIds]);
Map<Id,contact> contactMap = new Map<Id,contact>([Select Id from contact where Id IN: contactIds]);
List<account> accountinsert = new List<Account>();
List<Broker__c> brokers = new List<Broker__c>();
for(integer i=0; i<leadobject.size(); i++){
Id accId = leadobject.ConvertedAccountId; //at line 20 column 12 ERROR LINE
Id cId = leadobject.ConvertedContactId;   //at line 20 column 12    ERROR LINE
Account accountobj = accountMap.get(accId);
Contact contactobj = contactMap.get(cId);
Agency__c ag = new Agency__c();
ag.Name = accountobj.Name;
ag.Mailing_Address__c = accountobj.BillingStreet;
ag.City__c =accountobj.BillingCity;
ag.State__c = accountobj.BillingState;
ag.County__c = accountobj.County__c;
ag.Zip_Code__c = accountobj.BillingPostalCode;
ag.Account__c = accountobj.ConvertedAccountId;
ag.Phone__c = accountobj.Phone;
accountinsert.add(ag);
Broker__c b = new Broker__c();
b.Name = contactobj.Name;
b.Agency__c = accountobj.id;
b.Contact_ID__c = contactobj.Id;
brokers.add(b);
}
if( accountinsert.size()>0)
insert accountinsert;
if(brokers.size() > 0)
insert brokers;
}

 

how can solve this problem pls help me....................

  • January 23, 2012
  • Like
  • 0

i Created the Trigger for Lead Conversion to Custom object. Now i Need BulkTrigger for Lead Conversion. i can try but still i am not completed how to  create the BulkTrigger. in this Trigger i am using Two custom objects.i.e Agency and Broker once Lead is converted Lead Name goes to Broker and Company goes to Agency object.This code working fine but this not Bulk Process. i need BulkProcess for this Trigger.Please help me.................

Trigger

=======

trigger ConvertLead on Lead (after insert, after update) {

 

if (Trigger.new.size()> 0){

if(Trigger.new[0].isConverted == true && Trigger.new[0].Lead_type_picklist__c =='Broker') {
   

   if (Trigger.new[0].ConvertedAccountId != null){

for(Account a :[Select a.Id,a.Name,a.Description,a.BillingStreet,a.BillingState, a.BillingPostalCode, a.BillingCountry, a.BillingCity,a.county__c,a.phone From Account a Where a.Id =:Trigger.new[0].ConvertedAccountId]){
ag = new Agency__c();
ag.Name = a.Name;
ag.Mailing_Address__c = a.BillingStreet;
ag.City__c =a.BillingCity;
ag.State__c = a.BillingState;
ag.County__c = a.County__c;
ag.Zip_Code__c = a.BillingPostalCode;
ag.Account__c = Trigger.new[0].ConvertedAccountId;
ag.Phone__c = a.Phone;
}
insert ag;
}
List<Contact> con = new List<Contact>();
List<Broker__c> brokers = new List<Broker__c>();

if(Trigger.new[0].ConvertedContactId != null){

for(Contact c :[Select id,Name,Description,AccountId from Contact where Id = :Trigger.new[0].ConvertedContactId]){
Broker__c b = new Broker__c();
b.Name = c.Name;
b.Agency__c = ag.id;
b.Contact_ID__c = c.Id;
brokers.add(b);
}
insert brokers;
}
}
}
}

how can i created BulkProcess for this Trigger pls help................

  • January 23, 2012
  • Like
  • 0

i got new requirement from my client.  i created two custom objects i.e  Agency and Broker objects.

                  i.  Agency object is Master to Broker object.

                 ii. created Account lookup field in Agency object..

Task is  once Lead is  Converted then  company name goes to Agency object and FirstName and LastName goes to Broker object. this is the Task . I Created Trigger for this task. Comapany name goes to Agency object working properly but Broker object have Agency Requiredfield how can i get the Agency id  in Broker object.

 

My Trigger :

==========

trigger ConvertLead on Lead (after insert, after update) {
 
 if(Trigger.new.size() >0) {
    
    if(Trigger.new[0].isConverted == true && Trigger.new[0].Lead_type_picklist__c =='Broker') {
       
       List<Agency__c> agency = new List<Agency__c>();
       List<Account> acc = new List<Account>();
       List<Lead> lead = new List<Lead>();
       List<ID>   LIDs = new List<ID>();
       
       for(Lead l:Trigger.New){
           lead.add(l);
           LIDs.add(l.id);
       }
     
       if(Trigger.new[0].ConvertedAccountId != null){
          
          for(Account a :[Select a.Id,a.Name,a.Description,a.BillingStreet,a.BillingState, a.BillingPostalCode, a.BillingCountry, a.BillingCity  From Account a Where a.Id =:Trigger.new[0].ConvertedAccountId]){
              a.Description= Trigger.new[0].Name;
              acc.add(a);
              Agency__c ag = new Agency__c();
              ag.Name = a.Name;
              ag.Mailing_Address__c = a.BillingStreet;
              ag.City__c =a.BillingCity;
              ag.State__c = a.BillingState;
              ag.County__c = a.County__c;
              ag.Zip_Code__c = a.BillingPostalCode;
              ag.Account__c = Trigger.new[0].ConvertedAccountId;
              ag.Phone__c = a.Phone;
              agency .add(ag);
            }
             update acc;
             insert agency;
       }
        
           List<Contact> con = new List<Contact>();
           List<Broker__c>  brokers = new List<Broker__c>();
       
       if(Trigger.new[0].ConvertedContactId != null ) {
           for(Contact c :[Select id,Name,Description,AccountId  from Contact where  Id = :Trigger.new[0].ConvertedContactId]){
               c.Description = Trigger.new[0].Name;
               con.add(c);
             
               Broker__c  b = new Broker__c();
               b.Name = c.Name;
               b.Agency__c =
               b.Contact_ID__c = c.Id;
               brokers.add(b);
           }
              update con;
              insert brokers;
         }
       }
     }
   }

 

now i need Agency id how can solve this problem .Please help ...............      

  • January 19, 2012
  • Like
  • 0

1. i created the Trigger. Trigger use is once insert the records in Broker object automatically convert the records in contact object. once update the Broker object then Contact also updated.once delete the Broker object Contact also deleted.Trigger working Properly. but i need the Test Class for this Trigger. Test class code coverage is 13% how can i reach 75%. please help me .................

 

Trigger:

=====

 if(Trigger.isInsert){
        List<Contact> con = new List<Contact>();
        List<Broker__c> bro = new List<Broker__c>();
        List<Broker__c> UBList = new List<Broker__c>();
        List<ID> BIDs = new List<ID> {};
        for(Broker__c br:Trigger.New){
            bro.add(br);
            BIDs.add(br.id);
        }
      
        for(Broker__c b: bro) {
            Contact c = new Contact();
            c.LastName = b.Name;
            c.Title=b.Title__c;
            c.Contact_type__c=b.Broker_Type__c;
            c.Appointed_w_SeeChange__c=b.Appointed_with_SeeChange__c;
            c.RecordTypeId='012Z00000004JZS';
            c.Broker__c = b.Id;
           
            con.add(c);
        }
        insert con;
        
       Map<ID,Broker__c> UB = new Map<ID,Broker__c> {};
         for(Broker__c bc: [select id, contact_id__c, Agency__r.OwnerId from Broker__c where Id in : BIDs]) {
                UB.put(bc.Id,bc);
        }
        
        for(Contact c: con) {
            if(UB.containsKey(c.Broker__c)) {
                Broker__c UBCon = UB.get(c.Broker__c);
                UBCon.Contact_ID__c = c.Id;
                UBCon.Owner__c = UBCon.Agency__r.OwnerId;
                UBList.add(UBCon);
            }
        }
        update UBList;

    }    
    //Update Contact        
    if(Trigger.isUpdate){
        Map<ID,Broker__c> UB1 = new Map<ID,Broker__c> {};
        List<Contact> UpConList = new List<Contact> {};
        Set<ID> UBIDs = new Set<ID> {};
        for(Broker__c b: Trigger.new) {
            UB1.put(b.id,b);            
            UBIDs.add(b.id);
        }
        
        System.debug('Broker Map:'+UB1);
        for(Contact c: [select id, broker__c from contact where broker__c in :UBIDs]){
            Broker__c b = new Broker__c();
            if(UB1.containsKey(c.broker__c)) {
                b = UB1.get(c.broker__c);
                System.debug('Map get:'+b);
                c.LastName = b.Name;
                c.Title=b.Title__c;
                c.Contact_type__c=b.Broker_Type__c;
                c.Appointed_w_SeeChange__c=b.Appointed_with_SeeChange__c;
                c.Appointed_since__c=b.Appointed_Since__c;
                c.RecordTypeId='012Z00000004JZS';
                c.Broker__c = b.Id;
                UpConList.add(c);
            }
        }
        System.debug('UpConList:'+UpConList);
        update UpConList;
     }
     
    //Delete Contact
    if(Trigger.isDelete){
        List<ID> DBList = new List<ID>();
        List<Contact> DelConList = new List<Contact>();
        for(Broker__c b:Trigger.old) {
            DBList.add(b.id);
            System.debug('b value:'+b+'b.id:'+b.id);
        }  
        
        System.debug('DBList:'+DBList);
        DelConList = [select id from contact where Broker__c in :DBList];
        if(DelConList.size() >0) {
           delete DelConList;
        }
    }
 

i write the test class for Trigger. but showing this error Exception:System.ListException: Duplicate id in list:

 

how can solve this problem........

 

  • January 10, 2012
  • Like
  • 0

1. i created one custom object i.e  Broker__c.

2. in Contact object i created one lookup field to Broker__c object(Field Name : Broker__c(lookup))

3.i created trigger for  once inser the records in Broker object. that record convert to Contact object. and once i update the Broker object record then Contact object record also updated based on Broker id.

 

4. Now my requirement is i delete the Broker object record then Contact object record also deleted based on Broker id using trigger.i write code for delete the records.but records is not deleted this is my problem. pls help me......

 

Delete Trigger

================

 

 

if(Trigger.isDelete){
        List<ID> DBList = new List<ID>();
        System.debug('DBList:'+DBList);
        for(Broker__c b:Trigger.old) {
            DBList.add(b.id);
        }
        
       for( List<Contact> DelConList :[select id from contact where Broker__c in :DBList]){
        if(DelConList.size() >0) {
           System.debug('DelConList:'+DelConList);
           delete DelConList;
        }
    }

  • January 02, 2012
  • Like
  • 0

How to Create a Custom Related List. i created two custom objects i..e Agency and Broker object. i need to Account Related list under the Agency object.

1.i created Broker lookup field in Account object.

2.i Created Agency  MasterRelationship  field in Broker object.

 

Now i need AccountRelatedList under the Agency object. how can do this requirement . please help me any one.