Is there any REST service in Salesforce for converting interests into accounts?

We need to convert Account Summary using REST -OAuth calls. We can create, update fields (Edit) and Detail Lead, but we are not able to transform them.

We have found that this is possible using the SOAP API, but we only follow OAuth REST.

+7
source share
2 answers

Yes, and we solved this problem by creating an Apex class to call REST. Example code is -

@RestResource(urlMapping='/Lead/*') global with sharing class RestLeadConvert { @HttpGet global static String doGet() { String ret = 'fail'; RestRequest req = RestContext.request; RestResponse res = RestContext.response; String leadId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); Database.LeadConvert lc = new Database.LeadConvert(); lc.setLeadId(leadId); LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1]; lc.setConvertedStatus(convertStatus.MasterLabel); Database.LeadConvertResult lcr ; try{ lcr = Database.convertLead(lc); system.debug('*****lcr.isSuccess()'+lcr.isSuccess()); ret = 'ok'; } catch(exception ex){ system.debug('***NOT CONVERTED**'); } return ret; } } 

And you can use this call on

 <Your Instance URL>/services/apexrest/Lead/<LeadId> 

This test will give you about 93% coverage.

 @isTest public class RestLeadConvertTest{ static testMethod void testHttpGet() { Lead l = new Lead(); l.FirstName = 'First'; l.LastName = 'Last'; insert l; Test.startTest(); RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); req.requestURI = '/Lead/' + l.Id; req.httpMethod = 'GET'; RestContext.request = req; RestContext.response= res; RestLeadConvert.doGet(); Test.stopTest(); } } 
+9
source

This is actually an apex code, to which we do not have access for the apex. Is there a way without an apex code.

0
source

Source: https://habr.com/ru/post/956959/


All Articles