Creating Service Contract Using Global Method
The application allows you to create a Service Contract from a given Service Contract Plan using the Global method with the following details.
ServiceContractService
{
global static SVMXA360.SvmxGlobal.SvmxResponse createServiceContract(ServiceContractData serviceContractData){
return new SCON_ServiceContractPlanHandler().createServiceContract(serviceContractData);
}
Request Parameters
The following list explains the request parameters required to create a Service Contract record with the given Contract Plan.
Parameters
Mandatory (Yes/No)
Description
accountId
Yes
the SFDC record ID of the Account record.
startDate
Yes
the Start Date of the Service Contract.
endDate
No
the End Date of the Service Contract. If not provided, EndDate is calculated as StartDate + Duration in Plan.
pricebookId
No
the Pricebook to be used for Service Contract. If not provided, use it from Contract Plan's pricebook.
servicePlanProductId
Yes
the Product ID or ID of the Service Contract Plan in Service Contract Plan. When this is provided, use the Contract Plan that is linked to this ProductId. There should be only one Contract Plan for a given Product ID.
isCLIPlanProductId
No
The Boolean variable to look on Applicable Contract Line Product Id.
* 
You must provide the Product ID of the Contract Line Item Plan when the isCLIPlanProductId is true. Else, an error is displayed.
serviceContractName
Yes
the name of the Service Contract Name.
description
No
the description of the Service Contract that is to be created.
salesContractId
No
the record ID of the Sales Contract that is to be populated on a custom field on Service Contract.
salesContractIdFieldAPIName
No
the field name related to Sales Contract on Service Contract.
Request Body
The following API should be populated as the request body.
{
"accountId": "",
"startDate": "",
"endDate": "",
"pricebookId": "",
"servicePlanProductId": "",
"isCLIPlanProductId": "",
"serviceContractName": "",
"description": "",
"salesContractId": "",
"salesContractIdFieldAPIName": ""
}
How to Invoke API
// Create request object
ServiceContractData serviceContractData = new ServiceContractData();

// Populate data in the request
serviceContractData.accountId='lsdffss'; // SF Account record Id
serviceContractData.servicePlanProductId='wsfczdsda'; // SF Product Record Id
serviceContractData.startDate=System.today();
serviceContractData.serviceContractName='Test SCON';
serviceContractData.salesContractIdFieldName='Description'; // Custom/Managed Field API Name
serviceContractData.salesContractId='description field'; // Value for the Custom/Managed Field

// Calling Global method to create service contract
SVMXA360.SvmxGlobal.SvmxResponse response = ServiceContractService.createServiceContract(serviceContractData);
System.debug('Response: ' + response);
Response Parameters
The following list explains the response parameters.
Parameters
Description
accountId
the SFDC record Id of the Account record as provided in the request.
startDate
the Start Date of the Service Contract as provided in the request.
endDate
the End Date of the Service Contract as provided in the request.
pricebookId
the Pricebook to be used for the Service Contract as provided in the request.
servicePlanProductId
the Product Id or the ID of the Service Contract Plan in Service Contract Plan as provided in the request.
isCLIPlanProductId
the Boolean variable to look on Applicable Contract Line Product ID.
salesContractId
the record Id of the Sales Contract is to be populated on a custom field on the Service Contract as provided in the request.
salesContractIdFieldAPIName
the field name related to Sales Contract on Service Contract as provided in the request.
serviceContractId
the SFDC record id of the Service Contract that was created.
error
Any error would go under the error variable in SvmxGlobal class.
Response Body
The following API is received as the response body.
{
"success": true,
"message": "",
"data": {
"accountId": "",
"startDate": "",
"endDate": "",
"pricebookId": "",
"servicePlanProductId": "",
"isCLIPlanProductId": "",
"salesContractId": "",
"salesContractIdFieldAPIName": "",
"serviceContractId":""
},
"errors": []
}
Was this helpful?