This topic contains 12 replies, has 0 voices, and was last updated by fdumbuya 8 years, 7 months ago.
-
AuthorPosts
-
fdumbuya- Contributions: 0
- Level 1
- ☆
Hello,
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. -
khultquist- Contributions: 0
- Level 1
- ☆
Yes it’s possible, I run a very similar process with scripting.
-
fdumbuya- Contributions: 0
- Level 1
- ☆
Can you help me with it? I am a novice with scripting.
-
al3xicon- Contributions: 0
- Level 1
- ☆
Relatively 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.
-
khultquist- Contributions: 0
- Level 1
- ☆
Here’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 !!! } } } } }
-
fdumbuya- Contributions: 0
- Level 1
- ☆
Thanks Kultquist, I already have a saved search with the needed criteria. I will modify and run.
-
fdumbuya- Contributions: 0
- Level 1
- ☆
Hello 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.
-
k_dunc- Contributions: 0
- Level 1
- ☆
Hi 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.
-
carl.billings- Contributions: 0
- Level 1
- ☆
This is a really simple process with Workflow. I’ve done this for automated statements and invoices.
-
k_dunc- Contributions: 0
- Level 1
- ☆
Yep, 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.
-
webbee- Contributions: 0
- Level 1
- ☆
Yes, 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.
-
trimblee- Contributions: 0
- Level 1
- ☆
Workflow 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.
-
fdumbuya- Contributions: 0
- Level 1
- ☆
Hello 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.