Canceling Service Contract Using Global Method
The application allows you to cancel the Service Contract, Contract Line Items (CLI), and Entitled Service (ES) records using the Global method with the following details.
ServiceContractService
{
global static SVMXA360.SvmxGlobal.SvmxResponse cancelServiceContract(CancelServiceContractData cancelServiceContract){
return new SCON_ServiceContractPlanHandler().cancelServiceContract(cancelServiceContract);
}
Request Parameters
The following list explains the request parameters required to cancel the Service Contract, CLIs, and ES.
Parameters
Mandatory (Yes/No)
Description
salesContractId
Yes
the SFDC record ID of Sales Contract.
salesContractIdFieldAPIName
Yes
the API name of the Sales Contract field on Service Contract.
effectiveEndDate
Yes
the End Date to be updated on Contract.
cancellationReason
No
the reason for canceling the Contract.
cancellationReasonFieldAPIName
No
the field name in which the reason for cancellation is provided.
Request Body
The following API should be populated as the request body.
{
"salesContractId": "",
"salesContractIdFieldAPIName": "",
"effectiveEndDate": "",
"cancellationReason": "",
"cancellationReasonFieldAPIName": ""
}
How to Invoke
// Create request object
CancelServiceContractData cancelServiceContract = new CancelServiceContractData();

// Populate data in the request
cancelServiceContract.salesContractId = 'asdfw323432'; // SF Contract record Id
cancelServiceContract.salesContractIdFieldAPIName = 'Name';
cancelServiceContract.effectiveEndDate = Date.today().addYears(2);
cancelServiceContract.cancellationReason = 'Cancelling SC'; // Value for the Custom/Managed Field
cancelServiceContract.cancellationReasonFieldAPIName = 'Description'; // Custom/Managed Field API Name

// Calling Global method to create service contract
SVMXA360.SvmxGlobal.SvmxResponse response = ServiceContractService.cancelServiceContract(cancelServiceContract);
System.debug('Response: ' + response);
Response Parameters
The following list explains the response parameters.
Parameters
Description
salesContractId
the SFDC record ID of Sales Contract.
salesContractIdFieldAPIName
the API name of the Sales Contract field on Service Contract.
effectiveEndDate
the End Date to be updated on Contract.
cancellationReason
the reason for canceling the Contract.
cancellationReasonFieldAPIName
the field name in which the reason for cancellation is provided.
error
this goes in the errors variable of SvmxResponse class.
Response Body
The following APIs are the response body.
{
"success": true,
"message": "",
"data": {
"salesContractId": "",
"salesContractIdFieldAPIName": "",
"effectiveEndDate": "",
"cancellationReason": "",
"cancellationReasonFieldAPIName": ""
},
"errors": []
}
* 
The service finds out the Service Contract using the sales contract ID provided in the request. Ideally, there should be only one Contract for the given Sales Contract. But, if there is more than one contract found, then this service cancels all Contracts.
Was this helpful?