How to update base price on the price level of an ...
# ask-stanley-ai
v
How to update base price on the price level of an item under Sales/Pricing using a script?
c
AI generated answer (using internal Slack threads):
To update the base price on the price level of an item under Sales/Pricing using a script, you can use SuiteScript. Here is a general approach: 1. Load the item record using
record.load
method. 2. Get the sublist 'price' which contains the pricing information. 3. Loop through each line of the 'price' sublist. 4. For each line, check if the price level is the one you want to update. 5. If it is, use the
setSublistValue
method to update the 'price' field. 6. After updating all necessary lines, save the record using the
save
method. Here is a sample code snippet:
Copy code
javascript
var itemRecord = record.load({
    type: record.Type.INVENTORY_ITEM, // replace with your item type
    id: 'your_item_id'
});

var priceCount = itemRecord.getLineCount({sublistId: 'price'});

for (var i = 0; i < priceCount; i++) {
    var priceLevel = itemRecord.getSublistValue({
        sublistId: 'price',
        fieldId: 'pricelevel',
        line: i
    });

    if (priceLevel == 'your_price_level') { // replace with your price level
        itemRecord.setSublistValue({
            sublistId: 'price',
            fieldId: 'price',
            line: i,
            value: 'new_price' // replace with your new price
        });
    }
}

itemRecord.save();
Please replace
'your_item_id'
,
'your_price_level'
, and
'new_price'
with your actual item ID, price level, and new price respectively. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.879323184
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858366728
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844715655
Please provide your feedback on this answer.
v
priceCount getting -1