Home » Deeper in to NetSuite » Prevent Usage Limit Exceeded Exception In Client Script

Prevent Usage Limit Exceeded Exception In Client Script

Most of the time a situation comes in NetSuite where we need to upsert or delete hundreds or thousands of records either these are custom records or standard records. In this situation, we can upsert or delete all those records: 1) By writing scheduled script. 2) By Deleting Records From UI Using Inline Editing Feature. 3) By writing a client script. Most of the developers know about the above two methods. Some times we need to do the heavy job on client side which consumes API governance then we can use the third method. But there is one question arrives in one’s mind that NetSuite allows us 1000 units of API governance which are allocated to the client script and after consuming those units we get the SSS_USAGE_LIMIT_EXCEEDED exception. So how can we use third method? Yes, there exists one work around to accomplish the above job and preventing the SSS_USAGE_LIMIT_EXCEEDED exception. We can override the getRemainingUsage() of context object like:
nlapiGetContext().getRemainingUsage = function () {
    return 1000;
}
Standard definition is:
nlapiGetContext().getRemainingUsage = function () {
    return this.getTotalUsage() - (this.usage[this.getScriptId()] == null ? 0 : parseInt(this.usage[this.getScriptId()]));
}
It is very helpful for most of the times in many cases.

Get In Touch With Our Experts


    Heading to Display|Heading ID
    Most of the time a situation comes in NetSuite where we need to upsert or delete hundreds or thousands of records either these are custom records or standard records. In this situation, we can upsert or delete all those records: 1) By writing scheduled script. 2) By Deleting Records From UI Using Inline Editing Feature. 3) By writing a client script. Most of the developers know about the above two methods. Some times we need to do the heavy job on client side which consumes API governance then we can use the third method. But there is one question arrives in one’s mind that NetSuite allows us 1000 units of API governance which are allocated to the client script and after consuming those units we get the SSS_USAGE_LIMIT_EXCEEDED exception. So how can we use third method? Yes, there exists one work around to accomplish the above job and preventing the SSS_USAGE_LIMIT_EXCEEDED exception. We can override the getRemainingUsage() of context object like:
    nlapiGetContext().getRemainingUsage = function () {
        return 1000;
    }
    Standard definition is:
    nlapiGetContext().getRemainingUsage = function () {
        return this.getTotalUsage() - (this.usage[this.getScriptId()] == null ? 0 : parseInt(this.usage[this.getScriptId()]));
    }
    It is very helpful for most of the times in many cases.

    Get In Touch With Our Experts

      I have read and agree to the Privacy Policy of Folio3
      I agree to be contacted by Phone or Email by Folio3

      Get in touch with the

      Award-Winning

      End-to-end NetSuite Servicing Agency

      Tell us how may we assist you!