Hi guys, do you know how to get the categories lis...
# suitecommerce
b
Hi guys, do you know how to get the categories list data in a backend model with ss2? I need to get all the custom fields for each category so i can manipulate the display in the front.
s
I don't but I asked ChatGPT and it gave me this:
Copy code
var record = require('N/record');

function getCategories() {
    var categories = [];
    var categorySearch = search.create({
        type: "customrecord_ns_sc_category",
        filters: [
            ["isinactive", "is", "F"],
        ],
        columns: [
            search.createColumn({ name: "name", sort: search.Sort.ASC }),
            search.createColumn({ name: "internalid" }),
        ],
    });

    categorySearch.run().each(function(result) {
        categories.push({
            id: result.getValue("internalid"),
            name: result.getValue("name"),
        });
        return true;
    });

    return categories;
}
I don't think this'll work but 🤷🏻‍♂️ 😄
commercecategory
is a standard field so I don't know why it's using a custom record
b
Thank you so much, Steve!