Salesforce Apex-用于创建新潜在客户的现有联系人

Salesforce Apex-用于创建新潜在客户的现有联系人,salesforce,contact,apex,lead,Salesforce,Contact,Apex,Lead,我想为salesforce创建更新后的APEX,当联系人上的字段被选中为true时,它可以接受联系人并将其重新创建为Lead。任何帮助都将不胜感激 是的,所以我想我需要列出一个需要转移到潜在客户中的联系人列表。我忘记了从联系人那里获取字段的格式,这样我就可以将它们映射到lead中 public void createLead_Update(List<Contact> oldContacts, List<Contact> newContacts) { System.deb

我想为salesforce创建更新后的APEX,当联系人上的字段被选中为true时,它可以接受联系人并将其重新创建为Lead。任何帮助都将不胜感激

是的,所以我想我需要列出一个需要转移到潜在客户中的联系人列表。我忘记了从联系人那里获取字段的格式,这样我就可以将它们映射到lead中

public void createLead_Update(List<Contact> oldContacts, List<Contact> newContacts) {

System.debug('createLead_Update: entering trigger');

List<ID> createNewLead = new List<ID>();
Lead lead = new Lead(); 
Contact aContact = newContacts[i];


for (integer i=0; i<newContacts.size(); i++) {
// find contacts where the create lead checkbox is checked.
// on update, we care if the value is changed
Contact newValues = newContacts[i];
Contact oldValues = oldContacts[i];
if (newValues.createlead__c != oldValues.createlead__c) {
createNewLead.add(new Lead(
lead.firstName = aContact.firstName));
}
insert new lead
}
  System.debug('createLead_Update: exiting trigger');

    }
public void createLead\u更新(列出旧联系人,列出新联系人){
System.debug('createLead_Update:进入触发器');
List createNewLead=新列表();
铅铅=新铅();
触点A触点=新触点[i];
对于(整数i=0;i
List newLeadsList=newlist();

for(integer i=0;i你自己尝试过什么吗?@ChrisLava看看我这里有什么。我怎样才能将符合要求的联系人放入一个列表中,并一次全部上传?
List<Lead> newLeadsList= new List<Lead>();
for (integer i=0; i<newContacts.size(); i++) {
    if (newContacts[i].createlead__c != oldContacts[i].createlead__c && newContacts[i].createlead__c ) {
        newLeadsList.add(new Lead(lead.firstName = newContacts[i].firstName));
      }
}
insert newLeadsList;