Dynamically Grab Price Levels for Items in SuiteCommerce (SuiteScript)

in , September 27th, 2024
a person typing on a laptop on a table

Companies often wish to display various price levels on their SuiteCommerce website based on custom requirements. This can be achieved through SuiteScript!

The code example below allows you to dynamically grab an item's price level as needed. Feel free to use this code sample and edit it to meet your use case!

Note: The below example is for a Client Script, but this code is not limited to Client Scripts.

Example Code For Grabbing Item Price Levels

Remember to edit this code sample to function according to your unique requirements for displaying various price levels on your SuiteCommerce or SCA webstore.

define(["N/search"], function (search) {
    function sublistChanged(context) {
        //pass in some dynamic price level,
        //normally an integer representing the price level
        let someDynamicData = "1";
        //create price level string (default to baseprice)
        let priceLevel = !!someDynamicData 
            ? `price${someDynamicData}` 
            : "baseprice";
        //use an appropriate search to grab the price as a column, 
        //often using a join
        search.create({
              type: "item" //other record types may be used here,
              filters: [//add filter here],
              columns: [
                  search.createColumn({
                      name: priceLevel,
                      join: "item",
                  }),
              ],
          }).run().each(function (result) {
              //do something with the result
              return true;
          });
        return true;
    }
    return {
        sublistChanged: sublistChanged,
    };
});

Author: Sam Gagliardi


Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!


FREE SuiteCommerce Book

If you liked this article, you'll LOVE our book on SuiteCommerce! Order the free SuiteCommerce book today, and we'll even pay for shipping!

Oracle NetSuite Alliance Partner & Commerce Partner

If you have general questions about SuiteCommerce or more specific questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

We are a premium SuiteCommerce agency that creates powerful customer portals. Unlike our competitors, we have already solved your problems.


 
 

Want to keep learning?

Our team of NetSuite professionals has written articles on a wide variety of NetSuite topics, from SuiteCommerce tips, to recommended NetSuite solutions, to available support services, and more! 

Your cart