Dominik Antalik
12/18/2024, 8:04 AMCeligo AI
12/18/2024, 8:04 AMAI 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 set subscription's charges on invoice lines using SuiteScript, you can use a User Event Script to modify the invoice lines. Here is a sample script that changes the account on the invoice line:
javascript
/**
*@NApiVersion 2.1
*@NScriptType UserEventScript
*/
define(['N/record', 'N/log'],
(record, log) => {
const beforeSubmit = (context) => {
log.debug('L 2');
var invoiceRecord = context.newRecord;
try {
var numLines = invoiceRecord.getLineCount({
sublistId: 'item'
});
for (var i=0; i < numLines; i++) {
var currentAccount = invoiceRecord.getSublistText({
sublistId: 'item',
fieldId: 'account',
line: i
});
log.debug('current Account', currentAccount);
invoiceRecord.setSublistValue({
sublistId: 'item',
fieldId: 'account',
line: i,
value: 1037
});
var newAccount = invoiceRecord.getSublistValue({
sublistId: 'item',
fieldId: 'account',
line: i
});
log.debug('new Account', newAccount);
}
} catch (exception) {
log.debug(invoiceRecord.id + "-" + exception.message ? exception.message : exception);
}
}
return {
beforeSubmit: beforeSubmit
};
});
This script gets the invoice record and iterates over each line item. It then changes the account of each line item to a new account (in this case, account 1037).
Please note that you need to replace the account value with the internal ID of the account you want to set for the subscription charges. Also, ensure that the SuiteBilling module is enabled in your NetSuite account.
If you want to add a custom GL line to an invoice, you might need to use a plugin like the custom GL lines plugin. However, please note that this plugin is still in SuiteScript 1.0.
Remember to test this script in a sandbox environment before deploying it to production.Celigo AI
12/18/2024, 8:04 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810408771
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.809261858
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806178629
Celigo AI
12/18/2024, 8:04 AMCeligo AI
12/18/2024, 8:05 AM