Using the N/record api on an Invoice record, how d...
# ask-stanley-ai
a
Using the N/record api on an Invoice record, how do I find out if the currently selected line is a tax item?
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** To find out if the currently selected line is a tax item using the N/record API on an Invoice record, you can use the
getSublistValue
method. This method allows you to get the value of a field on a sublist line. Here is a sample code snippet:
Copy code
javascript
var taxCode = invoice.getSublistValue({
    sublistId: 'item',
    fieldId: 'taxcode',
    line: i
});
In this code, 'item' is the sublistId, 'taxcode' is the fieldId, and 'i' is the line number. The
getSublistValue
method will return the value of the 'taxcode' field on the 'item' sublist for the specified line number. If the returned value is a tax code or tax group, then the currently selected line is a tax item. If the returned value is not a tax code or tax group, then the currently selected line is not a tax item. Please note that this method should be used in dynamic mode. In dynamic mode, you need to select the line first using the
selectLine
method and commit the line after using the
commitLine
method. Here is a sample code snippet:
Copy code
javascript
invoice.selectLine({
    sublistId: 'item',
    line: i
});

var taxCode = invoice.getCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'taxcode'
});

invoice.commitLine({
    sublistId: 'item'
});
In this code, 'item' is the sublistId, 'taxcode' is the fieldId, and 'i' is the line number. The
getCurrentSublistValue
method will return the value of the 'taxcode' field on the 'item' sublist for the currently selected line. If the returned value is a tax code or tax group, then the currently selected line is a tax item. If the returned value is not a tax code or tax group, then the currently selected line is not a tax item.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823166192
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816507459
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813284457
Please provide your feedback on this answer.