I’m evaluating using consistent price levels. By that, I mean something that looks like this:
Keep in mind that you already have several superfluous price levels which you might want to delete. However, you cannot delete your Base Price (which I’m calling List Price) and Online Price. They are standard and must remain. All other price levels can be removed. So out of the box, you may choose to remove the three alternate price levels that come with NetSuite.
I had to make sure they were not associated with any customers. Here’s how I did that.
I’M DOING ALL THIS IN SANDBOX, and I’d highly recommend you do the same! Test your code before going live!
From this, I build a list of customers, including only the internalid and priceLevel properties. I needed this list to disassociate price levels I wanted to delete from all customers using that price level. This code clears all price levels except the Base Price (what I call List Price) from every customer in search results.
Then I updated customers to remove unwanted price levels. If you have more than 1,000 customers, you’ll need to break this operation up into pages. I’ve written other articles on how to do that. Here’s a tip.
And finally, Here’s the secret sauce for adding uniformly spaced price levels. There is a limit of 1,000 price levels. So plan these carefully for your organization’s needs.
And here’s the code in a form you can cut and paste into your Visual Studio project. I come with no guarantees. Use it at your own risk. Darned attornees!
class PricingLevelsAdd
{
static void Main(string[] args)
{
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Console.WriteLine(“Getting datacenter agnostic URL”);
NetSuiteService service = new DataCenterAwareNetSuiteService(TBAtoken.account);
service.Timeout = 1000 * 60 * 3;
List<PriceLevel> priceLevels = new List<PriceLevel>();
int i = 0;
for (double multiplier = 1; multiplier < 1000; multiplier++)
{
double discountPercent = 100 – (multiplier * 0.1);
string externalid = $”PL{discountPercent}”;
priceLevels.Add(
new PriceLevel()
{
name = String.Format(“{0:0.0}% Multiplier”, discountPercent)
, externalId = externalid
, discountpct = discountPercent
, discountpctSpecified = true
}
);
i++;
if (i % 25 == 0)
{
UpsertList(service, priceLevels);
i = 0;
}
}
if (i > 0) UpsertList(service, priceLevels);
Console.WriteLine(“Hit enter to close this window”);
Console.ReadLine();
}
private static void UpsertList(NetSuiteService service, List<PriceLevel> pricelevels)
{
service.tokenPassport = TBAtoken.createTokenPassport();
WriteResponseList writeResponseList = service.upsertList(pricelevels.ToArray());
int j = 0;
foreach (WriteResponse writeResponse in writeResponseList.writeResponse)
{
if (writeResponse.status.isSuccess)
{
Console.WriteLine($”{((PriceLevel) pricelevels[j]).name} – Success!”);
}
else
{
Console.WriteLine($”{((PriceLevel) pricelevels[j]).name} – Failed!”);
Console.WriteLine($”{writeResponse.status.statusDetail[0].message}”);
}
j++;
}
pricelevels.Clear();
}
}