/**
 * @NApiVersion 2.x
 * @NScriptType ScheduledScript
 * @Author: Ankith Ravindran <ankithravindran>
 * @Date:   2021-11-05T10:16:06+11:00
 * @Last modified by:   ankithravindran
 * @Last modified time: 2021-11-11T08:52:21+11:00
 */


define(['N/email', 'N/runtime', 'N/search', 'N/record'],
  function(email, runtime, search, record) {
    function execute(context) {

      //MPEX Customers - Commencing Today or Not Onboarded
      var custListCommenceTodayResults = search.load({
        type: 'customer',
        id: 'customsearch_cust_list_commence_today'
      });

      var count = 0;

      custListCommenceTodayResults.run().each(function(
        custListCommenceTodaySet) {

        count++;
        return true;
      });

      if (count > 0) {
        var reportLink =
          '<a href="https://1048144.app.netsuite.com/app/site/hosting/scriptlet.nl?script=1381&deploy=1">MPEX Customers - Day 1 Onboarding Customer Service Call</a>';

        //Email subject
        var subject =
          'Day 1 - MPEX Customers Onboarding Call';

        //Email Body
        var emailBody =
          'Dear Account Manager,</br></br>Please review customers and place a customer service call. </br>';
        emailBody += '<b><u>CUSTOMER COUNT</u></b>: ' +
          count + '</br>';

        emailBody += '<b><u>LINK</u></b>: ' + reportLink;

        emailBody +=
          '</br></br><b><u>Note</u></b>: If above link not clickable, please copy and paste in browser.'

        //Send email to the Sales Rep
        email.send({
          author: 112209,
          recipients: ['belinda.urbani@mailplus.com.au'],
          subject: subject,
          body: emailBody,
          cc: ['luke.forbes@mailplus.com.au', 'ankith.ravindran@mailplus.com.au']
        });
      }
    }

    function isNullorEmpty(val) {
      if (val == '' || val == null) {
        return true;
      } else {
        return false;
      }
    }

    return {
      execute: execute
    };
  });

[{"tag": "EMAIL", "value": "belinda.urbani@mailplus.com.au", "start": 1587, "end": 1617}, {"tag": "EMAIL", "value": "luke.forbes@mailplus.com.au", "start": 1692, "end": 1719}, {"tag": "EMAIL", "value": "ankith.ravindran@mailplus.com.au", "start": 1723, "end": 1755}]
/**
 * @NApiVersion 2.x
 * @NScriptType ScheduledScript
 * @Author: Ankith Ravindran <ankithravindran>
 * @Date:   2021-11-05T10:16:06+11:00
 * @Last modified by:   ankithravindran
 * @Last modified time: 2021-11-11T08:52:21+11:00
 */


define(['N/email', 'N/runtime', 'N/search', 'N/record'],
  function(email, runtime, search, record) {
    function execute(context) {

      //MPEX Customers - Commencing Today or Not Onboarded
      var custListCommenceTodayResults = search.load({
        type: 'customer',
        id: 'customsearch_cust_list_commence_today'
      });

      var count = 0;

      custListCommenceTodayResults.run().each(function(
        custListCommenceTodaySet) {

        count++;
        return true;
      });

      if (count > 0) {
        var reportLink =
          '<a href="https://1048144.app.netsuite.com/app/site/hosting/scriptlet.nl?script=1381&deploy=1">MPEX Customers - Day 1 Onboarding Customer Service Call</a>';

        //Email subject
        var subject =
          'Day 1 - MPEX Customers Onboarding Call';

        //Email Body
        var emailBody =
          'Dear Account Manager,</br></br>Please review customers and place a customer service call. </br>';
        emailBody += '<b><u>CUSTOMER COUNT</u></b>: ' +
          count + '</br>';

        emailBody += '<b><u>LINK</u></b>: ' + reportLink;

        emailBody +=
          '</br></br><b><u>Note</u></b>: If above link not clickable, please copy and paste in browser.'

        //Send email to the Sales Rep
        email.send({
          author: 112209,
          recipients: ['efpyi@example.com'],
          subject: subject,
          body: emailBody,
          cc: ['efpyi@example.com', 'envkt@example.com']
        });
      }
    }

    function isNullorEmpty(val) {
      if (val == '' || val == null) {
        return true;
      } else {
        return false;
      }
    }

    return {
      execute: execute
    };
  });

/**
 * @NApiVersion 2.x
 * @NScriptType ScheduledScript
 * @Author: Ankith Ravindran <ankithravindran>
 * @Date:   2021-11-05T10:16:06+11:00
 * @Last modified by:   ankithravindran
 * @Last modified time: 2021-11-11T08:52:21+11:00
 */


define(['N/email', 'N/runtime', 'N/search', 'N/record'],
  function(email, runtime, search, record) {
    function execute(context) {

      //MPEX Customers - Commencing Today or Not Onboarded
      var custListCommenceTodayResults = search.load({
        type: 'customer',
        id: 'customsearch_cust_list_commence_today'
      });

      var count = 0;

      custListCommenceTodayResults.run().each(function(
        custListCommenceTodaySet) {

        count++;
        return true;
      });

      if (count > 0) {
        var reportLink =
          '<a href="https://1048144.app.netsuite.com/app/site/hosting/scriptlet.nl?script=1381&deploy=1">MPEX Customers - Day 1 Onboarding Customer Service Call</a>';

        //Email subject
        var subject =
          'Day 1 - MPEX Customers Onboarding Call';

        //Email Body
        var emailBody =
          'Dear Account Manager,</br></br>Please review customers and place a customer service call. </br>';
        emailBody += '<b><u>CUSTOMER COUNT</u></b>: ' +
          count + '</br>';

        emailBody += '<b><u>LINK</u></b>: ' + reportLink;

        emailBody +=
          '</br></br><b><u>Note</u></b>: If above link not clickable, please copy and paste in browser.'

        //Send email to the Sales Rep
        email.send({
          author: 112209,
          recipients: ['PI:EMAIL:efpyi@example.comEND_PI'],
          subject: subject,
          body: emailBody,
          cc: ['PI:EMAIL:efpyi@example.comEND_PI', 'PI:EMAIL:envkt@example.comEND_PI']
        });
      }
    }

    function isNullorEmpty(val) {
      if (val == '' || val == null) {
        return true;
      } else {
        return false;
      }
    }

    return {
      execute: execute
    };
  });
