csc.CreateSuccessPlanFromOpportunityglobal with sharing class CreateSuccessPlanFromOpportunity Used to create success plans from opportunities. Exposes the API for mass creation of success plans from opportunities. Note: Ensure that no records related to the opportunity are already related to any success plans. MethodscreateSuccessPlansFromOpportunitiesglobal static List<csc.CreateSuccessPlanFromOppResponse> createSuccessPlansFromOpportunities(final List<csc.CreateSuccessPlanFromOppRequest> requests) Used to create multiple success plans from opportunities using a list of requests. Input Parameters
Return ValueList<CreateSuccessPlanFromOppResponse> Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
// Make a list of requests to call the API with.
final List<csc.CreateSuccessPlanFromOppRequest> requests = new List<csc.CreateSuccessPlanFromOppRequest>();
// Provide the ID of the opportunity that you want to create a success plan from.
// Note: Ensure that the opportunity and all related records are not already related to any success plans.
final Id opportunityId1 = '0068d00000DivKeAAJ';
// Make a map of fields to populate on the new success plan and values to populate them with.
// Note: If the csc__Opportunity__c field is populated, it will be overridden by opportunityId1.
final Map<SObjectField, Object> firstSuccessPlanFields = new Map<SObjectField, Object>{
csc__Success_Plan__c.Name => '1st API-generated success plan from opportunity'
};
// Instantiate a request by providing am opportunity Id and a map of fields to populate.
final csc.CreateSuccessPlanFromOppRequest firstRequest = new csc.CreateSuccessPlanFromOppRequest(
opportunityId1,
firstSuccessPlanFields
);
requests.add(firstRequest);
// Prepare parameters for any additional CreateSuccessPlanFromOppRequest instances to be created if needed.
final Id opportunityId2 = '0068d00000DivKbAAJ';
final Map<SObjectField, Object> secondSuccessPlanFields = new Map<SObjectField, Object>{
csc__Success_Plan__c.Name => '2nd API-generated success plan from opportunity'
};
// Instantiate an additional request if any
final csc.CreateSuccessPlanFromOppRequest secondRequest = new csc.CreateSuccessPlanFromOppRequest(
opportunityId2,
secondSuccessPlanFields
);
requests.add(secondRequest);
// Call the service with the list of requests.
final List<csc.CreateSuccessPlanFromOppResponse> responses = csc.CreateSuccessPlanFromOpportunity.createSuccessPlansFromOpportunities(
requests
);
|