我想从静态资源文件中获取代码中的值。我在静态资源中使用 excel 文件,我想知道如何将 excel 文件中的字段映射到代码中的 salesforce 字段。例如 Account.Name 等
铅 l = 新铅();l.Company = $Resource.EMailServicesLead.EmailServiceStaticResourceData.csv; \ Not Working EMailServicesLead - 静态资源的名称。EmailServiceStaticResourceData - 包含字段 {FirstName、LastName、Email、Company、Static、LeadSource} 的 csv 文件
/** * @File Name : myHandler.cls * @Description : * @Author : ChangeMeIn@UserSettingsUnder.SFDoc * @Group : * @Last Modified By : ChangeMeIn@UserSettingsUnder.SFDoc * @Last Modified On : 7/10/2019 , 3:54:01 PM * @Modification Log : * Ver Date Author Modification * 1.0 7/10/2019 ChangeMeIn@UserSettingsUnder.SFDoc Initial Version **/ global with sharing virtual class myHandler implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail (Messaging.InboundEmail 电子邮件,Messaging.InboundEnvelope 信封){ Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
//Lead l= (Lead)ListofLeadsStaticRes[0];
// List<SObject> ListofLeadsStaticRes = {!URLFOR($Resource.EMailServicesLead, 'EmailServiceStaticResourceData.csv')};
Integer j=0;
String myPlainText= '';
staticResource sr = new staticResource();
List<sObject> ls = Test.loadData(Lead.sObjectType, 'myResource');
// {!URLFOR($Resource.EMailServicesLead,EMailServicesLead/EmailServiceStaticResourceData.csv)}
Lead l = new Lead();
l.FirstName=email.fromName.substring(0,email.fromName.indexOf(''));
l.LastName=email.fromName.substring(email.fromName.indexOf(''));
l.Email = envelope.fromAddress;
myPlainText = email.plainTextBody;
l.Company = $Resource.EMailServicesLead.EmailServiceStaticResourceData.csv;
l.Status = $Resource.EMailServicesLead.EmailServiceStaticResourceData.csv;
l.LeadSource = $Resource.EMailServicesLead.EmailServiceStaticResourceData.csv;
l.Description = 'Mr.' + l.FirstName + l.LastName + ' enquired about the product Fin' + ' via' + ' Ëmail' + 'with body '+myPlainText;
Task[] newTask = new Task[0];
try { // Add a new Task to the Lead record we just found above.
List<Lead> vLed = [SELECT Id, Name, Email FROM Lead WHERE Email = :email.fromAddress LIMIT 1];
if(vLed.size()>0)
{ newTask.add(new Task(Description = myPlainText,
Priority = 'Normal',
Status = 'Inbound Email',
Subject = email.subject,
IsReminderSet = true,
ReminderDateTime = System.now()+1,
WhoId = vLed[0].Id));
insert newTask;
System.debug('New Task Object: ' + newTask );
}
else
{
insert l;
System.debug('Lead Created'+ l.Id);
}
}
catch (QueryException e) { System.debug('Query Issue: ' + e); }
return result;
}
}