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:

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.

Note:

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

method

string

Yes

Method name of the process to execute.

In this case, value must be sbCreateUsage to create usage records.

usages

array

Yes

Array list of usage objects to create.

usages[x].subscriptionId

number

Required if subscriptionName, sbLookup, and sbLineLookup are not provided.

Internal ID of the subscription record that you are creating usage for.

usages[x].subscriptionName

string

Required if subscriptionId, sbLookup, and sbLineLookup are not provided.

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.

usages[x].sbLookup

object

Required if subscriptionId, subscriptionName, and sbLineLookup are not provided.

Object containing the field ID and value which will be used for subscription lookup.

  • fieldId - Field ID on the subscription record to be used for subscription lookup.

  • value - Value of the field on the subscription record to be used for subscription lookup.

usages[x].line

number

Required if sbLineLookup is not provided.

Subscription line number that you want to create usage for.

usages[x].sbLineLookup

object

Required if subscriptionId, subscriptionName, and sbLookup are not provided.

Object containing the field ID and value which will be used for subscription line lookup.

  • fieldId - Field ID on the subscription line record to be used for subscription line lookup.

  • value - Value of the field on the subscription line record to be used for subscription line lookup.

usages[x].quantity

number

Yes

Quantity of usage to be created.

usages[x].date

date

Yes

Date of usage to be created.

Date format must follow the format specified in the account preference.

usages[x].memo

string

No

Notes that you want to include on the usage record.

usages[x].customFields

array

No

Array list of custom field objects with field ID - value pairs. The custom fields are set on the usage record.

  • fieldId - Field ID on the usage record which will be set with the value provided.

  • value - Value to be set in the custom field 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

requestId

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
} 

          

General Notices