Asset 360 Suite > Asset 360 for End Users > Service Contracts > Service Contract Creation Using APIs > Adding Services to Service Contract or Asset Using Global Method
Adding Services to Service Contract or Asset Using Global Method
The application allows you to add Entitled Services (ES) to a Service Contract or Asset(s) record using the Global method with the following details.
ServiceContractService
{
global static SVMXA360.SvmxGlobal.SvmxResponse createEntitledServices(EntitledServiceData entitledServiceData){
return new SCON_ServiceContractPlanHandler().createEntitledServices(entitledServiceData);
}
Request Parameters
The following list explains the request parameters required to add Entitled Services (ES) to a Service Contract or Asset(s).
Parameters
Mandatory (Yes/No)
Description
serviceContractId
Yes
the ID of the Service Contract for which the ES needs to be created.
contractLineItemId
No
the record Id of the CLIs for which the ES needs to be created.
startDate
Yes
the Start Date of the CLI.
endDate
No
the End Date of the CLI. If not provided, the EndDate is calculated as StartDate + Duration in Plan.
entitledServiceName
Yes
the name of Entitled Service.
serviceProductId
Yes
the product ID.
serviceUnit
Yes
the type of service.
serviceQty
Yes
the quantity of the service in numbers.
thresholdAlert
No
workOrderEntitlementProcess
No
the ID of the WO Entitlement process, both of the entitlement process cannot be provided.
caseEntitlementProcess
No
the ID of the Case Entitlement process, both of the entitlement process cannot be provided.
subscriptionId
No
the ID of the Subscription object which needs to be copied to one of the ESs field.
subscriptionFieldName
No
the field name on ES which is lookup to Subscription object.
subscribedAssetId
No
the ID of the Subscription object which needs to be copied to one of the ES's field.
subscribedAssetFieldName
No
the field name on ES which is lookup to Subscribed Asset object.
Request Body
The following API should be populated as the request body.
{
"serviceContractId": "",
"contractLineItemId": "",
"startDate": "",
"endDate": "",
"entitledServiceName": "",
"serviceProductId": "",
"serviceUnit": "",
"serviceQty": "",
"thresholdAlert": "",
"workOrderEntitlementProcess": "",
"caseEntitlementProcess": "",
"subscriptionId": "",
"subscriptionFieldName": "",
"subscribedAssetId": "",
"subscribedAssetFieldName": ""
}
How to Invoke
// Create request object
EntitledServiceData entitledServiceData = new EntitledServiceData();

// Populate data in the request
entitledServiceData.entitledServiceName = 'New ES-1';
entitledServiceData.serviceContractId = 'lsdffss'; // SF Service Contract record Id
entitledServiceData.contractLineItemId = 'fssd3223'; // SF Contract Line Item record Id
entitledServiceData.serviceProductId = '342342'; // SF Product record Id
entitledServiceData.serviceUnit = 'Hours';
entitledServiceData.serviceQty = '15';
entitledServiceData.subscriptionFieldName = 'Type'; // Custom/Managed Field API Name
entitledServiceData.subscriptionId = 'Phone Support'; // Value for the Custom/Managed Field


// Calling Global method to create service contract
SVMXA360.SvmxGlobal.SvmxResponse response = ServiceContractService.createEntitledServices(entitledServiceData);
System.debug('Response: ' + response);
Response Parameters
The following list explains the response parameters.
Parameters
Description
serviceContractId
the ID of Service Contract for which the ES needs to be created.
contractLineItemId
the record Id of the CLIs for which the ES needs to be created.
startDate
the Start Date of the CLI.
endDate
the End Date of the CLI. If not provided, the EndDate is calculated as StartDate + Duration in Plan.
entitledServiceName
the name of Entitled Service.
serviceProductId
the product ID.
serviceUnit
the type of service.
serviceQty
the quantity of the service in numbers.
thresholdAlert
workOrderEntitlementProcess
the ID of the WO Entitlement process, both of the entitlement processes cannot be provided.
caseEntitlementProcess
the ID of the Case Entitlement process, both of the entitlement processes cannot be provided.
subscriptionId
the ID of the Subscription object which needs to be copied to one of the ES's fields.
subscriptionFieldName
the field name on ES which is a lookup to Subscription object.
subscribedAssetId
the ID of the Subscription object which needs to be copied to one of the ES's fields.
subscribedAssetFieldName
the field name on ES which is a lookup to Subscribed Asset object.
entitledServiceId
the record ID of the ES created.
error
this goes in the errors variable of SvmxResponse class.
Response Body
The following APIs are the response body.
{
"success": true,
"message": "",
"data": {
"serviceContractId": "",
"contractLineItemId": "",
"startDate": "",
"endDate": "",
"entitledServiceName": "",
"serviceProductId": "",
"serviceUnit": "",
"serviceQty": "",
"thresholdAlert": "",
"workOrderEntitlementProcess": "",
"caseEntitlementProcess": "",
"subscriptionId": "",
"subscriptionFieldName": "",
"subscribedAssetId": "",
"subscribedAssetFieldName": "",
"entitledServiceId":""
},
"errors": []
}
* 
If there is an ES already available for an Asset (CLI), then add the serviceQty to the existing record's quantity. If there is more than one record found, it shows an error message "more than one ES record found with the same product".
If there is an ES already available for the Contract, then add the serviceQty to the existing record's quantity. If there is more than one record found, it shows an error message "more than one ES record found with the same product".
CPLIs related to the ES are not created as there is no CPLI Plan provided from which you can create CPLI.
Was this helpful?