Triggers 失败消息:“错误消息”;System.QueryException:没有此类列';地址';关于实体';领先者';。我

Triggers 失败消息:“错误消息”;System.QueryException:没有此类列';地址';关于实体';领先者';。我,triggers,salesforce,apex-code,apex,Triggers,Salesforce,Apex Code,Apex,我通过了salesforce apex在沙盒中的所有测试覆盖率,但在部署到live中获得了 题目有误,我不知道怎么处理。 我的测试类代码是: 以及我在触发器中调用的类代码: 看起来问题是基于代码中未包含的soql查询的。您尝试查询名为“地址”的字段,但该字段不存在。地址仍在测试中 尝试调整查询并使用“城市”、“街道”、“国家”和“邮政编码”字段 您可以在那里了解有关sObject字段的更多信息:以防其他人遇到此问题 正如Christian所说,代码试图在SOQL查询中从Lead访问“Addres

我通过了salesforce apex在沙盒中的所有测试覆盖率,但在部署到live中获得了 题目有误,我不知道怎么处理。 我的测试类代码是:

以及我在触发器中调用的类代码:


看起来问题是基于代码中未包含的soql查询的。您尝试查询名为“地址”的字段,但该字段不存在。地址仍在测试中

尝试调整查询并使用“城市”、“街道”、“国家”和“邮政编码”字段


您可以在那里了解有关sObject字段的更多信息:

以防其他人遇到此问题

正如Christian所说,代码试图在SOQL查询中从Lead访问“Address”字段。从API版本30开始,可以在查询()中使用复合字段


因此,如果您在代码中遇到了这个问题,请检查类的API版本和visualforce页面。两者都必须是30或更大。

好的,谢谢,但它与live side上的安装包冲突,当我卸载该包并重试时,我获得了成功并部署了Diaz,从您对Christian的评论来看,您似乎解决了您的问题。最好是对你自己的问题发表一个答案,并接受它作为正确答案。
@isTest(SeeAllData=true)
public class myLeadTest{ 

 public static testMethod void testMyController5() {

                Account acc= new Account(name='test');
                acc.Order__c='wee';
                insert acc;

                Campaign camp = new Campaign(Name='test');
                insert camp;

                Company__c cm= new Company__c();
                cm.Company_Id__c=12;
                cm.Name='234';
                cm.Account__c=acc.id;
                insert cm;


                Lead l= new Lead();
                l.Campaign__c=camp.Id;
                l.LastName='test';
                l.Company='cmpny';
                l.Company_Id__c=cm.Company_Id__c;
                l.Email='test@yahoo.com';
                l.Status='Closed - Converted';


                l.Order__c=acc.Order__c;


               // l.Auto_Convert__c=true;
               // l.IsConverted=false;

                //l.ConvertedAccountId=acc.Id;
                Lead[] l2= new Lead[]{l};
                insert l2;

                Opportunity op= new Opportunity ();
                op.StageName='Won (Agency)';
                op.Name='test';
                op.CloseDate=Date.valueOf('2015-04-28');
                op.AccountId=acc.id;
                op.LeadSource='web';
                op.StageName= 'Won (Agency)';
                op.CampaignId=camp.id;
                op.TrialStart__c=Date.valueOf('2012-04-28');  
                insert op;

                Contact cnt= new Contact();
                cnt.LastName='test';
                cnt.AccountId=acc.id;
                cnt.ASEO_Company_Id__c=12;
                cnt.Email=l.Email;
                cnt.Company__c=cm.id;
                insert cnt;

                ///////////////
            /*    Lead l5= new Lead();
                l5.Campaign__c=camp.Id;
                l5.LastName='test';
                l5.Company='cmpny';
                l5.Company_Id__c=12;
                l5.Email='test@yahoo.com';
                l5.Status='Closed-Converted';
                l5.isConverted=false;
                //l.ConvertedAccountId=acc.Id;              
                insert l5; */
                Contact cnt1= new Contact(); 
                cnt1.LastName='test';
                cnt1.AccountId=acc.id;
                cnt1.ASEO_Company_Id__c=12;
                cnt1.Email=l.Email;  
                insert cnt1;                
                Database.LeadConvert leadConvert = new Database.LeadConvert();
                  leadConvert.setLeadId(l2[0].Id);
                  LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
                  leadConvert.setConvertedStatus(convertStatus.MasterLabel);
                  leadConvert.setOpportunityName(op.Name);
                  leadConvert.setConvertedStatus('Closed - Converted');
                  Database.LeadConvertResult lcResult = Database.ConvertLead(leadConvert);
                //  MyLead.addCampaign(l2[0], camp.Name);
                //  MyLead.updateOpportunity(l2[0], lcResult);

              //   MyLead.updateContact( l2[0], lcResult, cm) ;            
               //  myLead.addCampaignMembers(l2);


                }

}
public class MyLead {
    public static void convertLead(Lead[] leads) {
      Database.LeadConvert leadConvert = new Database.LeadConvert();
      for (Lead lead :leads) {
        if (!(lead.IsConverted)) {
          // Check if an account exists with email. Attach Contact and Account, convert Lead.
          Contact[] myContacts = [SELECT Id, AccountId FROM Contact WHERE Email = :lead.Email Limit 1];
          if (myContacts.size() == 1) {
            System.debug('Existing Contact');
            MyLead.attachExistingConvert(lead, myContacts[0]);
          }
          else {
            System.debug('No existing contact');
            if (lead.Auto_Convert__c) {

             MyLead.addCampaign(lead, lead.Campaign__c);

              leadConvert.setLeadId(lead.Id);
              leadConvert.setConvertedStatus('Closed - Converted');
              Database.LeadConvertResult lcResult = Database.ConvertLead(leadConvert);

              // Populate the newly created records with extra data.
              MyLead.updateOpportunity(lead, lcResult);
              Company__c myCompany = [SELECT Id FROM Company__c WHERE Company_Id__c = :lead.Company_Id__c];
              MyLead.updateContact(lead, lcResult, myCompany);
              // Must update the Company before Account otherwise the Account lookup will fail.
              MyLead.updateCompany(lead, lcResult, myCompany);
              MyLead.updateAccount(lead, lcResult, myCompany);
            }
          }
        }
      }
    }

    // Attaches Lead to Contact and Account if matched by Email, converts Lead and creates opportunity if it doesn't exist.
    public static void attachExistingConvert(Lead lead, Contact contact) {
        MyLead.addCampaign(lead, lead.Campaign__c);
        Database.leadConvert leadConvert = new Database.LeadConvert();
        leadConvert.setLeadId(lead.Id);
        leadConvert.setConvertedStatus('Closed - Converted');
        leadConvert.setContactId(contact.Id);
        leadConvert.setAccountId(contact.AccountId);
        leadConvert.setSendNotificationEmail(True);
        // Do not create an opportunity if any exist.
        Opportunity[] myOpportunity = [SELECT Id FROM Opportunity WHERE AccountId = :contact.AccountId];
        if (myOpportunity.size() > 0) {
          leadConvert.setDoNotCreateOpportunity(True);
        }
        leadConvert.setLeadId(lead.Id);
        Database.LeadConvertResult leadConvertResult = Database.convertLead(leadConvert);
        // If we created an opportunity, update it with extra stuff.
        if (leadConvert.isDoNotCreateOpportunity() == False) {
          MyLead.updateOpportunity(lead, leadConvertResult);
        }
    }

    // Updates the newly created Opportunity with extra data
    public static void updateOpportunity(Lead lead, Database.LeadConvertResult lcResult) {
      Opportunity myOpportunity = [SELECT Id, StageName FROM Opportunity WHERE Id = :lcResult.opportunityId];
      myOpportunity.Name = 'Online Upgrade';
      myOpportunity.TrialStart__c = lead.CreatedDate.date();
      //myOpportunity.Amount = lead.Monthly_Revenue__c;
      myOpportunity.Amount = lead.Amount__c;
      myOpportunity.Type = 'New Business';
      myOpportunity.LeadSource = 'Website';
      myOpportunity.Order__c = lead.Order__c;
      DateTime dt = System.now();
      Date d = dt.date(); 
      myOpportunity.CloseDate = d;
      myOpportunity.StageName = lead.Agency__c ? 'Won (Agency)' : 'Won (End User)';
      myOpportunity.Probability = 100;

      update myOpportunity;
    }

    // Updates the newly created Account with extra data 
    public static void updateAccount(Lead lead, Database.LeadConvertResult lcResult, Company__c myCompany) {
      Account myAccount = [SELECT Id FROM Account WHERE Id = :lcResult.accountId];
      myAccount.Type = 'Customer';
      myAccount.ASEO_Company_Id__c = lead.Company_Id__c;
      myAccount.Company__c = myCompany.Id; // Setting the company will cause the company account lookup to fail
      myAccount.Order__c = lead.Order__c;

      update myAccount;
    }

    // Updates the newly created Contact with extra data 
    public static void updateContact(Lead lead, Database.LeadConvertResult lcResult, Company__c myCompany) {
      Contact myContact = [SELECT Id FROM Contact WHERE Id = :lcResult.contactId];
      myContact.ASEO_Company_Id__c = lead.Company_Id__c;
      myContact.Company__c = myCompany.Id;

      update myContact;
    }

    // Updates the Company with extra data 
    public static void updateCompany(Lead lead, Database.LeadConvertResult lcResult, Company__c myCompany) {
      myCompany.Account__c = lcResult.accountId;

      update myCompany;
    }

    // Adds a lead to a campaign
    public static void addCampaign(Lead lead, String campaign) {

      Campaign[] myCampaigns = [Select Id FROM Campaign WHERE Name = :campaign LIMIT 1];
      if (myCampaigns.size() == 1) {
        CampaignMember campaignMember = new CampaignMember (campaignId=myCampaigns[0].Id, leadId=lead.Id);
        insert campaignMember;
      }
    }
    // Create campaign members from leads. Campaign comes from lead.Campaign__c.
    public static void addCampaignMembers(Lead[] leads) {
      for (Lead lead :leads) {
        // Might want to query Campaigns table instead.
        //Set<String> campaigns = new Set<String>();
        //campaigns.add('Freemium');
        Campaign[] myCampaigns = [SELECT Id FROM Campaign WHERE Name = :lead.Campaign__c LIMIT 1];

        //if (campaigns.contains(lead.Campaign__c)) {
        if (myCampaigns.size() == 1) {
          MyLead.addCampaign(lead, lead.Campaign__c);
        }
      }
     } 

}
trigger LeadTrigger on Lead (after insert, after update) {
    Lead[] leads = Trigger.new;
    //MyLead.createOpportunity(leads);
    MyLead.convertLead(leads);

Please any one can help me, i tries 25 times but in deploying to production  give me error in the given subject, or any one give code coverage of this class,  thank you in advance