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.

It's only fair to share...Tweet about this on TwitterShare on LinkedInShare on Google+Share on Facebook
Available Quantity of Kit/Package Items
How to Customize the NetSuite Search API to Search For 1000+ Records in NetSuite

Zeeshan Ahmed

Leave a Reply

Your email address will not be published.

12 − eight =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

ContactUs.com