how do i create an inventory adjustment record in ...
# ask-stanley-ai
e
how do i create an inventory adjustment record in SuiteScript
c
AI generated answer (using internal Slack threads):
To create an inventory adjustment record in SuiteScript, you can use the
record
module to create a new record, set the necessary fields, and then add lines to the 'inventory' sublist. Here is a sample code snippet based on the conversations:
Copy code
javascript
var record = require('N/record');

var inventoryAdjustmentRecord = record.create({
    type: record.Type.INVENTORY_ADJUSTMENT,
    isDynamic: true,
});

// Set necessary fields
inventoryAdjustmentRecord.setValue({
    fieldId: 'subsidiary',
    value: 1, // replace with your subsidiary id
});

inventoryAdjustmentRecord.setValue({
    fieldId: 'account',
    value: 112, // replace with your account id
});

// Add lines to the 'inventory' sublist
inventoryAdjustmentRecord.selectNewLine({
    sublistId: 'inventory',
});

inventoryAdjustmentRecord.setCurrentSublistValue({
    sublistId: 'inventory',
    fieldId: 'item',
    value: 100, // replace with your item id
});

inventoryAdjustmentRecord.setCurrentSublistValue({
    sublistId: 'inventory',
    fieldId: 'location',
    value: 1, // replace with your location id
});

inventoryAdjustmentRecord.setCurrentSublistValue({
    sublistId: 'inventory',
    fieldId: 'adjustqtyby',
    value: 10, // replace with the quantity to adjust by
});

inventoryAdjustmentRecord.commitLine({
    sublistId: 'inventory',
});

// Save the record
var recordId = inventoryAdjustmentRecord.save({
    enableSourcing: true,
    ignoreMandatoryFields: true
});
Please replace the placeholder values with your actual data. Also, if your inventory items have lot numbers or serial numbers, you need to handle the inventory detail subrecord accordingly. ****** 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.861933947
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.843837678
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840241492
Please provide your feedback on this answer.