What type of field type do I need to use in sublis...
# ask-stanley-ai
r
What type of field type do I need to use in sublist.addField if I want to update with transactions?
c
AI generated answer (using internal Slack threads):
To update a field in a sublist with transactions, you would need to use the
Record.setSublistValue
or
Record.setCurrentSublistValue
methods in SuiteScript 2.0. These methods allow you to set the value of a field on the current sublist line in dynamic or standard mode respectively. Here is an example of how you might use these methods:
Copy code
javascript
var record = record.load({
    type: record.Type.SALES_ORDER, 
    id: '123'
});

// For dynamic mode
record.selectNewLine({
    sublistId: 'item'
});
record.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'quantity',
    value: '2'
});
record.commitLine({
    sublistId: 'item'
});

// For standard mode
record.setSublistValue({
    sublistId: 'item',
    fieldId: 'quantity',
    line: 1,
    value: '2'
});
In this example, we're updating the 'quantity' field on the 'item' sublist of a Sales Order record. The
selectNewLine
method is used to select a new line on the sublist in dynamic mode, and
commitLine
is used to save the changes to the line. In standard mode, you can directly set the value of a field on a specific line using
setSublistValue
. ****** 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.837561905
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.81700021
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813084424
Please provide your feedback on this answer.