This topic contains 12 replies, has 0 voices, and was last updated by fdumbuya 8 years, 7 months ago.
-
AuthorPosts
-
March 21, 2016 at 8:34 am #5319
fdumbuyaHello,
Can someone please help me with this issue. We are trying to automate the email notices to customers for 15 and 30 days and would also like to put a copy of the message with each invoice under the Communication tab. Is that possible?
This is a cached copy. Click here to see the original post. -
March 21, 2016 at 8:49 am #5320
khultquistYes it’s possible, I run a very similar process with scripting.
-
March 21, 2016 at 9:29 am #5321
fdumbuyaCan you help me with it? I am a novice with scripting.
-
March 21, 2016 at 9:43 am #5322
al3xiconRelatively easy with scripting, I’ve set this up for clients as well – however there is a NetSuite “dunning” feature that is supposed to accomplish this – I believe it is available as a SuiteBundle / Suiteapp – I have not tried it yet though.
-
March 21, 2016 at 9:44 am #5323
khultquistHere’s the script… it should be rewritten to clean up the date function and use parameters, but it is working. There are also custom fields in the script that you will need to edit.
Code:
function find_late_invoice(type) { //set minimum overdue days and increment of days between emails var min_days = 15; var increment_days = 7; var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds var today = new Date(); var search_date = new Date(); search_date.setDate(search_date.getDate() – min_days); var limit_date = new Date(); limit_date.setDate(search_date.getDate() – 365); // Run only when scheduled if (type == ‘scheduled’) { var invoice_filters = []; invoice_filters.push(new nlobjSearchFilter(‘duedate’, null, ‘onorbefore’, search_date)); invoice_filters.push(new nlobjSearchFilter(‘duedate’, null, ‘after’, limit_date)); invoice_filters.push(new nlobjSearchFilter(‘amountremaining’, null, ‘greaterthan’, 0)); invoice_filters.push(new nlobjSearchFilter(‘mainline’, null, ‘is’, ‘T’)); invoice_filters.push(new nlobjSearchFilter(‘custentityopt_out_invoice_emails’, ‘customer’, ‘is’, ‘F’)); invoice_filters.push(new nlobjSearchFilter(‘custrecordsend_late_invoice_reminders’, ‘subsidiary’, ‘is’, ‘T’)); var invoice_columns = []; invoice_columns.push(new nlobjSearchColumn(‘tranid’, null, null)); invoice_columns.push(new nlobjSearchColumn(‘status’, null, null)); invoice_columns.push(new nlobjSearchColumn(‘duedate’, null, null)); invoice_columns.push(new nlobjSearchColumn(’email’, ‘customer’, null)); invoice_columns.push(new nlobjSearchColumn(‘internalid’, null, null)); //Search for invoice var late_invoice = nlapiSearchRecord(‘invoice’, null, invoice_filters, invoice_columns); // step through results for(var i = 0; late_invoice && i < late_invoice.length; i++) { var this_invoice = late_invoice[i]; var duedate = this_invoice.getValue('duedate'); var invoice_number = this_invoice.getValue('tranid'); var invoice_id = this_invoice.getValue('internalid'); var send_to = this_invoice.getValue('email', 'customer'); // fix date formatting issue var duedate_parts=duedate.split("/"); var duedate_formatted = new Date( duedate_parts[2], duedate_parts[0] -1, duedate_parts[1]); var diff_days = Math.round(Math.abs((today.getTime() – duedate_formatted.getTime())/(oneDay))); // check to see if today is the right increment of days if (Math.round((diff_days-min_days)/increment_days) == ((diff_days-min_days)/increment_days) ) { var subject = 'Past Due Invoice ' + invoice_number ; // create body text var body = 'Payment for invoice '; body += invoice_number ; body += ' is '; body += diff_days; body += ' days overdue. Please advise when payment will be made.'; body += ' If payment has already been made, please disregard this email.'; var bcc = []; bcc[0] = 'example@example.com'; // transaction record var records = {}; // Create a new record object records.transaction = invoice_id; // Print the Record as PDF var attachment = nlapiPrintRecord('TRANSACTION', invoice_id, 'PDF', null); // Check for blank email address if (send_to === '' || send_to === null) { send_to = 'default@example.com'; subject = 'No Email Address – ' + subject; } // send email if status is Open if (this_invoice.getText('status') == 'Open') { nlapiSendEmail(9, send_to, subject, body, null, bcc, records, attachment); // modify sender !!! } } } } }
-
March 21, 2016 at 10:33 am #5324
fdumbuyaThanks Kultquist, I already have a saved search with the needed criteria. I will modify and run.
-
March 21, 2016 at 10:37 am #5325
fdumbuyaHello al3xicon, thanks for the info on Dunning. Had already checked on the Dunning, it is an add on application and we have not bought that yet. However, if you can send me some sample code, I’d appreciate it.
-
March 21, 2016 at 5:37 pm #5326
k_duncHi fdumbuya, you should be able to achieve this through a Workflow too. I’ve created a Dunning Workflow that sends out an automated email and a copy of that email is then accessible through the Communication subtab. This Workflow is scheduled to run weekly and is predicated on a Saved Search that I created. Hope that helps.
-
March 22, 2016 at 3:59 pm #5327
carl.billingsThis is a really simple process with Workflow. I’ve done this for automated statements and invoices.
-
March 22, 2016 at 4:53 pm #5328
k_duncYep, Carl is correct. My Workflow contains just the one State and the one Action – Send Email. It is a Scheduled Workflow that runs from a Saved Search.
-
March 23, 2016 at 12:00 am #5329
webbeeYes, in this case we don’t required to use any script. As it can be done using scheduled workflow which will sent mail based on saved search. System will also have record after sending mail.
-
March 23, 2016 at 3:10 pm #5330
trimbleeWorkflow vs script choice on this is impacted by where the email(s) are located that you need to send to. They can be any of customer record, contact records, or the annoying “Email” field on the Sales Order.
The dunning module is very good if it fits your requirements well, though it still has bugs, some significant.
-
April 1, 2016 at 12:36 pm #5331
fdumbuyaHello all,
Thank you all very much for the help. I used the Workflow with one state and sent the emails and it is working fine now.
-
AuthorPosts
You must be logged in to reply to this topic.