how to use CurrentRecord.setCurrentMatrixSublistVa...
# ask-stanley-ai
n
how to use CurrentRecord.setCurrentMatrixSublistValue to set the price levels of an inventory item using suitescript?
c
AI generated answer (using internal Slack threads):
To set the price levels of an inventory item using SuiteScript, you can use the
setCurrentMatrixSublistValue
method. This method is used to set the value of a matrix sublist field on the current matrix sublist line. Here is a sample code snippet that demonstrates how to use this method:
Copy code
javascript
var itemRecord = record.load ({
    type: record.Type.INVENTORY_ITEM,
    id: itemId
});

var qtyPriceSchedule = itemRecord.getValue({
    fieldId: 'quantitypricingschedule'
});

// Set the base price
var basePrice = 100;

// You must select, set, and then commit the sublist line you want to change.
itemRecord.selectLine({
    sublistId: priceID,
    line: 1
});
itemRecord.setCurrentMatrixSublistValue({
    sublistId: priceID,
    fieldId: 'price',
    column: 1,
    value: basePrice
});
itemRecord.commitLine({
    sublistId: priceID
});

// Get the number of columns in the price matrix
// Each column represents a different quantity level
columnCount = itemRecord.getMatrixHeaderCount({
    sublistId: priceID,
    fieldId: 'price'
});
In this code snippet,
record.load
is used to load the inventory item record. The
selectLine
method is used to select the sublist line that you want to change. The
setCurrentMatrixSublistValue
method is used to set the value of the 'price' field on the current matrix sublist line. The
commitLine
method is used to save the changes to the sublist line. Finally,
getMatrixHeaderCount
is used to get the number of columns in the price matrix. Please note that the
priceID
in the code snippet should be replaced with the actual sublist ID that you are working with. ****** 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.85369873
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851532
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849212706
Please provide your feedback on this answer.