Skip to content

Instantly share code, notes, and snippets.

@pokotyamu
Last active January 19, 2017 08:51
Show Gist options
  • Save pokotyamu/304c8eb26a0764b18d7ec219f292778a to your computer and use it in GitHub Desktop.
Save pokotyamu/304c8eb26a0764b18d7ec219f292778a to your computer and use it in GitHub Desktop.
リードから取引先に昇格させる
@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