简体   繁体   English

简单销售转换潜在客户

[英]simple-salesforce convert lead

I'm pretty new to the salesforce api. 我对Salesforce API很陌生。 I've been employing the python module simple-salesforce in order to create leads. 我一直在使用python模块simple-salesforce来创建销售线索。 It works great, but it's really unclear to me how to do non-CRUDlike actions. 它的效果很好,但对我来说真的很不清楚如何执行非CRUD式的动作。 For example, I want to programatically convert a lead into an account . 例如,我想以编程方式将销售lead转换为account

The salesforce GUI makes this easy. salesforce GUI使此操作变得容易。 One would simply open the lead , then click the convert button. 只需打开lead ,然后单击convert按钮即可。 Does anyone out there know how to do this with simple-salesforce ? 有谁知道如何通过simple-salesforce人员做到这一点?

UPDATE UPDATE

I found this describing the creation of an APEX resource Is there any REST service available in Saleforce to Convert Leads into Accounts? 我发现这描述了APEX资源的创建,Saleforce中是否有可用的REST服务将潜在客户转换为客户?

I'm hoping there is a more elegant way to achieve this but I'll post what I do with simple salesforce's apex support if that's what ends up happening. 我希望有一种更优雅的方法来实现这一目标,但是如果最终发生这种情况,我将发布我对简单的Salesforce的最高支持的支持。

It looks like the best way to deal with this problem is to create an APEX class as detailed in the linked post. 看来解决此问题的最佳方法是创建一个APEX类,如链接文章中所述。 After creating that class, you can use simple salesforce to query it like this: 创建该类之后,您可以使用简单的salesforce进行如下查询:

        conversion_result = sf.apexecute('Lead/{id}'.format(id=lead_result['id']), method='GET')

A tip to anyone trying this: please make sure you create the class in a sandbox account. 给任何尝试此方法的人的提示:请确保您在沙盒帐户中创建该类。 I tried for a good 20 minutes to create the apex class in our production environment without realizing that salesforce doesn't let you do that. 我花了20分钟时间在生产环境中创建顶点类,但没有意识到Salesforce不允许您这样做。

After making the changes in your sandbox you need to upload them to production. 在沙盒中进行更改后,您需要将其上传到生产环境。 Of course, the environments are not connected by default! 当然,默认情况下不连接环境! Here is an explanation on how to allow uploads to your production environment. 是有关如何允许上传到生产环境的说明。

UPDATE: 更新:

Here is the test class I created for the linked APEX class. 这是我为链接的APEX类创建的测试类。 Salesforce requires test classes with 75% coverage. Salesforce要求测试类别的覆盖率达到75%。 This doesn't actually test any functionality, it just passes Salesforce's arbitrary requirements. 这实际上并没有测试任何功能,只是通过了Salesforce的任意要求。

@isTest
class RestLeadConvertTest{
    @isTest static void testIt(){
    Lead lead = new Lead();
    lead.LastName = 'salesforce';
    lead.Company = 'unittest';
    insert lead;

   RestRequest req = new RestRequest(); 
   RestResponse res = new RestResponse();

   req.requestURI = '/services/apexrest/Lead/' + lead.Id;  //Request URL
   req.httpMethod = 'GET';//HTTP Request Type
   RestContext.request = req;
   RestContext.response= res;

   RestLeadConvert.doGet();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM