Asset 360 Suite > Asset 360 for End Users > Service Contracts > Service Contract Creation Using APIs > Adding Assets to Service Contract Using Global Method
Adding Assets to Service Contract Using Global Method
The application allows you to create Contract Line Items for a given Contract using the following global method.
ServiceContractService
{
global static SVMXA360.SvmxGlobal.SvmxResponse createContractLineItems(ContractLineItemData contractLineItemData){
return new SCON_ServiceContractPlanHandler().createContractLineItems(contractLineItemData);
}
Parameters for Contract Line Item Data
This method creates Contract Line Items (CLIs) for the given Assets and Contract Plan by using the following parameters.
Parameters
Mandatory (Yes/No)
Description
servicePlanProductId
No
the ID of Service Contract Plan using which the CLIs need to be created.
isCLIPlanProductId
No
The Boolean variable to look on Applicable Contract Line Product ID.
serviceContractId
Yes
the ID of the Service Contract record.
assetDataList
Yes
list of Assets to be added to the Service Contract
Request Parameters
Use the following parameters to get a collection of Assets linked to a Contract Plan.
Parameters
Mandatory (Yes/No)
Description
assetId
Yes
the record ID of the Asset that needs to be added as CLI. This Asset can be any Asset but should match the Product in CLI Plan. It should be in line with interactive authoring.
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.
pricebookEntryId
No
the pricebook Entry ID or the Product ID. If provided, use that. If not, then use it from the Service Contract's pricebook. It throws an error if the ID in pricebook is not matching.
subscriptionId
No
the ID of the Subscription object that needs to be copied to one of the CLI fields.
subscriptionFieldName
No
the field name on CLI, which is a lookup to Subscription object.
subscribedAssetId
No
the ID of the Subscription object that needs to be copied to one of the CLI's fields.
subscribedAssetFieldName
No
the field name on CLI, which is a lookup to Subscribed Asset object.
Request Body
The following API should be populated as the request body.
{
"servicePlanProductId": "",
"serviceContractId": "",
"assetId": "",
"startDate": "",
"endDate": "",
"pricebookEntryId": "",
"subscriptionId": "",
"subscriptionFieldName": "",
"subscribedAssetId": "",
"subscribedAssetFieldName": ""
}
How to Invoke
// Create request object
ContractLineItemData contractLineItemData = new ContractLineItemData();

// Populate data in the request
contractLineItemData.servicePlanProductId = 'adgf33243'; //SF Product Record Id
contractLineItemData.serviceContractId = 'lsdffss'; // SF Service Contract record Id

//Asset data list
List<ContractLineAssetData> assetDataList = new List<ContractLineAssetData>();
ContractLineAssetData contractLineAssetData = new ContractLineAssetData();
ContractLineAssetData.assetId = 'lsdffss'; // SF Asset record Id
ContractLineAssetData.startDate = Date.today();
ContractLineAssetData.endDate = ContractLineAssetData.startDate.addDays(30);
assetDataList.add(ContractLineAssetData);

contractLineItemData.assetDataList = assetDataList;

SVMXA360.SvmxGlobal.SvmxResponse response = ServiceContractService.createContractLineItems(contractLineItemData);
System.debug('Response: ' + response);
Response Parameters
The following list explains the response parameters.
Parameters
Description
servicePlanProductId
the ID of Service Contract Plan using which the CLIs need to be created.
isCLIPlanProductId
The Boolean variable to look on Applicable Contract Line Product ID.
serviceContractId
the ID of Service Contract for which the CLIs need to be created.
assetId
the record ID of the Asset that needs to be added as CLI. This Asset can be any Asset but should match the Product in CLI Plan. It should be in line with interactive authoring.
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.
pricebookEntryId
the pricebook Entry ID or the Product ID. If provided, use that. If not, then use it from the Service Contract's pricebook. It throws an error if the ID in pricebook is not matching.
subscriptionId
the ID of the Subscription object that needs to be copied to one of the CLI fields.
subscriptionFieldName
the field name on CLI, which is a lookup to Subscription object.
subscribedAssetId
the ID of the Subscription object that needs to be copied to one of the CLI's fields.
subscribedAssetFieldName
the field name on CLI, which is a lookup to Subscribed Asset object.
contractLineItemId
the SFDC record Id of the CLI 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": {
"servicePlanProductId": "",
"serviceContractId": "",
"assetId": "",
"startDate": "",
"endDate": "",
"pricebookEntryId": "",
"subscriptionId": "",
"subscriptionFieldName": "",
"subscribedAssetId": "",
"subscribedAssetFieldName": "",
"contractLineItemId":""
},
"errors": []
}
Was this helpful?