sbCreateUsage
Use this method to send a request to create usage records for subscription items in NetSuite.
When the RESTlet receives a request using this method, it performs the following tasks:
-
creates a SuiteBilling operation record
-
runs or queues the SuiteBilling operation map/reduce script that will process the usage creation
Even if the usage creation process is not yet finished, the RESTlet also immediately returns the request ID in the response object. You can use the request ID to determine the status of the usage data creation request using the sbGetUsageCreationStatus method.
When the map/reduce script runs, it processes the SuiteBilling operation record created in the request. A SuiteBilling operation detail record is created for each usage object.
Usage creation processing time increases when the number of usage objects in the request increases. For information about how to optimize the performance of the map/reduce script for usage creation, see Optimizing the Performance of the SuiteBilling Enhancement Script.
Request Properties
Property |
Data Type |
Required? |
Description |
---|---|---|---|
|
string |
Yes |
Method name of the process to execute. In this case, value must be |
|
array |
Yes |
Array list of usage objects to create. |
|
number |
Required if |
Internal ID of the subscription record that you are creating usage for. |
|
string |
Required if |
Name of the subscription record that you are creating usage for.
Important:
If the subscription name that you provided is used for multiple subscriptions, an error will be returned. |
|
object |
Required if |
Object containing the field ID and value which will be used for subscription lookup.
|
|
number |
Required if |
Subscription line number that you want to create usage for. |
|
object |
Required if |
Object containing the field ID and value which will be used for subscription line lookup.
|
|
number |
Yes |
Quantity of usage to be created. |
|
date |
Yes |
Date of usage to be created. Date format must follow the format specified in the account preference. |
|
string |
No |
Notes that you want to include on the usage record. |
|
array |
No |
Array list of custom field objects with field ID - value pairs. The custom fields are set on the usage record.
|
Sample Request
{
"method": "sbCreateUsage",
"usages": [{
"subscriptionId": "1",
"line": "3",
"quantity": "5",
"date": "1/3/2018",
"memo": "this is a note"
}, {
"subscriptionName": "Test Sub 001 - 1/1/2018",
"line": "1",
"quantity": "3",
"date": "1/4/2018"
}, {
"sbLookup": {
"fieldId": "custrecord_sb_service_id",
"value": "1001"
},
"line": "4",
"quantity": "10",
"date": "1/4/2018"
}, {
"sbLineLookup": {
"fieldId": "custrecord_sb_line_service_id",
"value": "1234"
},
"quantity": "10",
"date": "1/4/2018"
}, {
"subscriptionName": "USD Free One Month Trial - 2/4/2018",
"line": "1",
"quantity": "5",
"date": "2/4/2018",
"customFields": [{
"fieldId": "custrecord_usage_source",
"value": "data"
}, {
"fieldId": "custrecord_usage_unit",
"value": "MB"
}]
}]
}
Response Properties
If the SuiteBilling operation record for the request is successfully created, the following property is returned.
Property |
Data Type |
Description |
---|---|---|
|
number |
Internal ID of the SuiteBilling operation record. You can use this value to get the status of the usage creation. |
Sample Response
{
"requestId": 101
}