Everything NetSuite

A Blog by Dave Weiss

Manipulating NetSuite Billing Rate Cards Using SuiteScript

By Dave Weiss, Published on September 23rd, 2021
Tags: NetSuiteERP SuiteScript Integration

Billing Rate Cards and Billing Classes are not exposed to the NetSuite SuiteTalk API. If you're using the SOAP/XML web service to access NetSuite, that leaves you in a pickle if you need to access or edit this data.

While integrating the Financial Force PSA system with NetSuite projects, I needed to detemine if a particular Billing Class existed, and create the Billing Class if it did not. Then, the rates for the new Billing Class had to be created in a given Project's Billing Rate Card.

The workaround solution I created is to use a NetSuite RESTLet that can do both of these tasks. The RESTLet is invoked as part of the integration, passing in a JSON object containing a Project Internal ID and Billing Class name. Here is the basic flow for the solution:

  1. Make a saved search in NetSuite that contains the Billing Classes. I like calling saved searches when possible, because it's easier to modify a saved search if necessary rather than re-write code for on-the-fly searches. Additionally, saved searches are much more performant than searches created via SuiteScript at runtime.
  2. Call the saved Billing Class search within the RESTLet with a filter on the Billing Class name, using the Billing Class name from the JSON object. If there are no results, that means you have to create the Billing Class. If the Billing Class does exist, get and save the Billing Class ID, as you'll need it later. If you have to create the Billing Class, make sure you save the ID when executing the "save" method.
  3. Get the Billing Rate Card from the Project using the Project ID in the JSON object. Using the "lookupFields" method on the SuiteScript record module should do the trick. If there is no Billing Rate Card on the project, throw an error.
  4. Once you have the Billing Rate Card's ID, you can load the record and find the Billing Class row on the Rate Card using the "findSublistLineWithValue" method on the record. Supply the Billing Class ID as the value to find, and the 'billingclassid' as the field to search. One caveat to finding the proper row to edit is to know if you are using multiple currencies. If you are, the sublistId you need to search in is called 'ratecardpricingmulti'. If you are not using multiple currencies, it is 'ratecardpricing'.
  5. Now that you've found the row to edit, you can edit the price(s) with a 'setSublistValue' call on the proper sublist, then save the Billing Rate Card.

That's it! Now you can manage Billing Rate Cards in an integration.