sbGetUsageCreationStatus

Use this method to get the status and results of the usage creation request made using the sbCreateUsage method. Use the request ID returned by the sbCreateUsage method when you send a request using this method.

When the RESTlet receives a request using this method, it searches for the SuiteBilling operation record associated with the request ID. If an operation record is found, the method returns the usage creation status in the response object.

Request Properties

Property

Data Type

Required?

Description

method

string

Yes

Method name of the process to execute.

In this case, value must be sbGetUsageCreationStatus to check the status of the usage creation.

requestId

number

Yes

Internal ID of the SuiteBilling operation record.

This value is returned by the sbCreateUsage method used for the usage creation request.

Sample Request

            {
    "method": "sbGetUsageCreationStatus",
    "requestId": "1101"
} 

          

Response Properties

Property

Data Type

Description

requestId

number

Internal ID of the SuiteBilling operation record.

status

string

Status of the usage creation.

Value can be one of the following:

  • Not Started

  • In Progress

  • Completed

  • Error

result

object

Result object that contains the information of successful records, failed records, and unhandled errors.

result.successes

array

Array list of usage objects that are successfully created.

Each object contains the index, data, and result.

  • index - Position or index of the usage object in the usage array.

  • data - Usage object in the usage array

  • result - Resulting object after processing the usage object. This property holds the internal ID of the created usage record.

result.failures

array

Array list of usage objects that failed.

Each object contains index, data, and result.

  • index - Position or index of the usage object in the usage array.

  • data - Usage object in the usage array.

  • result - Resulting object after processing the usage object. This property holds the error information that describes why a usage record is not created.

result.errors

array

Array list of error information that occurred on the different stages of the map/reduce script.

These errors occurred outside the scope of usage creation (that is, outside of SuiteBilling Operation Detail record creation).

  • stage - Stage in the map/reduce script where the error occurred.

  • key - Key property of the context object. This value is usually the unique key processed in the map/reduce stages.

  • name - Code or title of the error.

  • message - Descriptive information about the error.

Sample Response

The following example shows the response when the operation record for the specified request ID is successfully obtained. In this example, the status of the usage creation is completed, one record is successfully created, one record failed, and there are no unhandled errors.

            {
    "requestId": "1101",
    "status": "Completed",
    "result": {
        "successes": [
            {
                "index": 0,
                "data": {
                    "subscription": "1",
                    "line": "3",
                    "quantity": "5",
                    "date": "1/3/2018",
                    "memo": "this is a note"
                },
                "result": {
                    "usageId": 101
                }
            }
        ],
        "failures": [
            {
                "index": 1,
                "data": {
                    "subscription": "1",
                    "line": "5",
                    "quantity": "15",
                    "date": "1/3/2018"
                },
                "result": {
                    "name": "INVALID_KEY_OR_REF",
                    "message": "Invalid usagesubscriptionline reference key Ems SP 001 - 1/1/2018: 5."
                }
            }
        ],
        "errors": []
    }
} 

          

In the following example, the status of the usage creation is completed and there is one unhandled error.

            {
    "requestId": "1102",
    "status": "Completed",
    "result": {
        "successes": [],
        "failures": [],
        "errors": [
            {
                "stage": "reduce",
                "key":"906",
                "name":"UNEXPECTED_ERROR",
                "message":"An unexpected error occurred."
            }
        ]
    }
} 

          

General Notices