How to get the behavior of the Next Bill button, i...
# ask-stanley-ai
a
How to get the behavior of the Next Bill button, in a suitescript, including having it follow Billing Schedules?
1
c
AI generated answer (using internal Slack threads):
To get the behavior of the "Next Bill" button in a SuiteScript and have it follow Billing Schedules, you can use the
nlapiTransformRecord
function. However, this function will bill the entire Sales Order (SO) regardless of the billing schedules attached. To overcome this, you can set the
billdate
in your script. Unfortunately, there is no direct way to do this in a workflow. Another approach is to pay attention to the URL parameters when you press the "Next Bill" button on your Sales Order. These parameters are default values that you need to set while transforming the invoice. Here is a sample code snippet:
Copy code
javascript
var record = nlapiTransformRecord('salesorder', salesOrderId, 'invoice');
record.setFieldValue('trandate', nextBillDate);
var invoiceId = nlapiSubmitRecord(record, true, true);
In this code,
salesOrderId
is the ID of the Sales Order you want to bill, and
nextBillDate
is the date of the next bill according to the billing schedule. Please note that this is a simplified example and you may need to adjust it according to your specific requirements. ****** 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.840515137
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837646544
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836792052
Please provide your feedback on this answer.
a
I found out from StackOverflow that the correct way to do this is const thisBillDate = salesOrderSearchResult.getValue({name: "nextbilldate"}); record.transform with a defaultValues object like {billdate: thisBillDate} in it