• Gus proto
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
Is there a way to import the salesforce metadata back into salesforce?
I would to export export lead list view metadata change the sobject from lead to account and load it back. I can retrieve it with workbench but i dnt know how to load it back.
I am running into cpu limit with this am I am missing somthing? And also how can I adjust the code to avoid harcoding the ID like i did.
Trigger AutoConverter on Lead (after insert,after update) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted ) {
               Database.LeadConvert lc = new Database.LeadConvert();
            
               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(TRUE); 
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
                String leadOwner = lead.OwnerId;
              if(leadOwner.startsWith('00G')){
               Lc.OwnerId = '00535000001ZOZN'; }
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}

 
How do I convert this trigger into a batch apex class so i can process over 5 millions record,
Trigger AutoConverter on Lead (after insert,after update) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted ) {
               Database.LeadConvert lc = new Database.LeadConvert();

               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(TRUE); 
               lc.setConvertedStatus(convertStatus.MasterLabel);

                String leadOwner = lead.OwnerId;
              if(leadOwner.startsWith('00G')){
               Lc.OwnerId = '00535000001ZOZN'; }
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}

 
How do I convert this trigger into a batch apex class so i can process over 5 millions record,
Trigger AutoConverter on Lead (after insert,after update) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted ) {
               Database.LeadConvert lc = new Database.LeadConvert();

               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(TRUE); 
               lc.setConvertedStatus(convertStatus.MasterLabel);

                String leadOwner = lead.OwnerId;
              if(leadOwner.startsWith('00G')){
               Lc.OwnerId = '00535000001ZOZN'; }
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}