QueryResult result1 = connection.query("select id, Name from Campaign where id='" + campaignId +
"'");
LeadDetails lead = new LeadDetails();
lead.setFirstName(leadDeatils.getFirstName());
lead.setLastName(leadDeatils.getLastName());
lead.setSalutation("Mrs.");
lead.setIndus("sasadd");
Campaign campaign = (Campaign)result1.getRecords()[0];
lead.setCampaign(campaign);
SaveResult[] sr = connection.create(new SObject[] { lead });
我是新来的。请帮帮我。谢谢你。是什么,使用SOAP API将lead发送到SF的集成吗?
您必须联系负责该Salesforce组织的管理员/开发人员。从Lead到Campaign没有标准的查找,所以从2021年开始没有什么强制性的。这里是标准字段的列表。下面是实体关系图,显示了Leads(和Contacts)通过名为Campaign member的多对多帮助表链接到Campaign。(左下)。
无论你得到什么错误-它可能是新的自定义字段/验证规则/其他一些东西在你的组织SF管理员没有通知集成团队。
注:如果你有活动id并且在lead或其他地方有自定义Campaign__c
字段-你不需要查询它吗?你可以叫它lead.setCampaign(campaignId );
或者类似的东西?
添加活动成员获得修复
CampaignMember campaignMember = new CampaignMember();
campaignMember.setCampaignId(campaignId);
campaignMember.setLeadId(leadId);
SaveResult[] result = connection.create(new SObject[] { campaignMember });
if (result.length == 1 && result[0].isSuccess()) {
System.out.println("LeadAssignment.setCampaignMember() : " + result);
// lead.setAttachments(attachResult.getClass());;
} else {
System.out.println("LeadAssignment.setCampaignMember() : Campaign member added on lead " + leadId);
}