This topic contains 12 replies, has 0 voices, and was last updated by fdumbuya 8 years, 7 months ago.

  • Author
    Posts
  • #5319

    fdumbuya

    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.

  • #5320

    khultquist

    Yes it’s possible, I run a very similar process with scripting.

  • #5321

    fdumbuya

    Can you help me with it? I am a novice with scripting.

  • #5322

    al3xicon

    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.

  • #5323

    khultquist

    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 !!! } } } } }

  • #5324

    fdumbuya

    Thanks Kultquist, I already have a saved search with the needed criteria. I will modify and run.

  • #5325

    fdumbuya

    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.

  • #5326

    k_dunc

    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.

  • #5327

    carl.billings

    This is a really simple process with Workflow. I’ve done this for automated statements and invoices.

  • #5328

    k_dunc

    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.

  • #5329

    webbee

    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.

  • #5330

    trimblee

    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.

  • #5331

    fdumbuya

    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.

You must be logged in to reply to this topic.