REST Service to Convert Leads into Accounts in Saleforce
Following restservice can be used to convert leads to accounts in Sales
Call this service as
YOUR_ENV_NAME/services/apexrest/Lead/
@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; } }
Call this service as
YOUR_ENV_NAME/services/apexrest/Lead/
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.