Last active
January 19, 2017 08:51
-
-
Save pokotyamu/304c8eb26a0764b18d7ec219f292778a to your computer and use it in GitHub Desktop.
リードから取引先に昇格させる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestResource(urlMapping='/LeadManager/*') | |
global class LeadManager { | |
@HttpPost | |
global static List<String> convert() { | |
RestRequest request = RestContext.request; | |
String leadId = request.params.get('leadId'); | |
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); | |
//取引開始時に不要な商談を作らない | |
lc.setDoNotCreateOpportunity(true); | |
Database.LeadConvertResult lcr = Database.convertLead(lc); | |
Product__c product = new Product__c(product_usage_status__c = '有料利用中', | |
product_name__c = 'dfplus.io', | |
account_name__c = request.params.get('identifier'), | |
charge_plan_name__c = request.params.get('plan'), | |
company_name__c = lcr.getAccountId()); | |
insert product; | |
List<String> result = new List<String>(); | |
result.add(lcr.getAccountId()); | |
result.add(product.Id); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment