add custom line (not associated with any existing ...
# ask-stanley-ai
l
add custom line (not associated with any existing item) to a sales order when creating it through the rest api
c
AI generated answer (using internal Slack threads):
To add a custom line (not associated with any existing item) to a sales order when creating it through the REST API, you can use the
insertLine
method in SuiteScript. This method allows you to insert a new line into a sublist at a specific index. Here is a sample code snippet:
Copy code
javascript
var rec = record.create({
    type: record.Type.SALES_ORDER,
    isDynamic: true,
});

// Add other necessary fields

// Add a custom line
rec.selectNewLine({
    sublistId: 'item'
});
rec.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'item',
    value: 'custom_item_id' // replace with your custom item id
});
rec.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'quantity',
    value: 1
});
rec.commitLine({
    sublistId: 'item'
});

var recordId = rec.save();
In this example, a new sales order is created, a new line is selected in the 'item' sublist, and then the item and quantity are set for that line. The line is then committed to the sales order. Replace 'custom_item_id' with the ID of your custom item. Please note that this is a simplified example and you may need to add additional fields or logic to suit your specific needs. ****** 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.820567966
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815418243
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.803657055
Please provide your feedback on this answer.