Scheduled Script for Getting Network Status of E-Documents

The Electronic Invoicing SuiteApp provides a script to automatically get network status for bulk transactions. The script has an additional parameter Transactions Filtering Plugin ID (id: custscript_ei_filtertransid). This parameter populates the implementation id of the Transactions Filtering Plugin ID field, which contains the logic for filtering transactions. By default, the script selects transactions if the following conditions are met:

By default, the script’s status is set to Scheduled and it runs every 2 hours. The administrator can set a different schedule as per their requirements.

Implementing Transaction Filtering Plug-in

The Electronic Invoicing SuiteApp has added a custom plug-in type called the Transaction Filtering Plugin (id: customscript_transactionfilterplugin). This plug-in contains the following method which the administrator must implement:

getFilteredTransactions: This method filters the transactions for which the Automatic Get Network Status MR script updates the statuses. The method returns an array of objects. The objects have two keys that contain the details of transactions.

The details of objects in the returned array are given in the following table:

Parameter

Type

Description

id

String

It is the unique number to identify the transaction.

recordType

String

It specifies the type of transaction.

In the default implementation, the getFilteredTransactions method returns the list of transactions where:

          /**
 * @NApiVersion 2.x
 * @NModuleScope Public
 * @NScriptType plugintypeimpl
 */
define(["N/search", "N/format"], function (search, format) {
  /**
   * getFilteredTransactions - This function is the entry point of our plugin script
   *
   * @returns {Array} transactions
   * @returns {Object} transaction
   * @returns {String} transaction.recordType
   * @returns {String} transaction.id
   */
  function getFilteredTransactions() {
    var transactions = [];
    var yesterdayDate = new Date();
    yesterdayDate.setDate(yesterdayDate.getDate() - 1);
    var transSearch = search.create({
      type: search.Type.TRANSACTION,
 
      filters: [
        [
          "trandate",
          search.Operator.NOTBEFORE,
          format.format({
            value: yesterdayDate,
            type: format.Type.DATE,
          }),
        ],
        "and",
        ["custbody_ei_network_id", search.Operator.ISNOTEMPTY, ""],
        "and",
        ["mainline", "is", "T"],
      ],
    });
    var PAGE_SIZE = 1000;
 
    var searchResult = transSearch.runPaged({ pageSize: PAGE_SIZE });
    searchResult.pageRanges.forEach(function (pageRange) {
      var currPage = searchResult.fetch({ index: pageRange.index });
 
      currPage.data.forEach(function (result) {
        transactions.push({
          recordType: result.recordType,
          id: result.id,
        });
      });
    });
    return transactions;
  }
 
  return {
    getFilteredTransactions: getFilteredTransactions,
  };
}); 

        

The administrator must add a plug-in implementation for the Transaction Filtering Plugin type. You must provide the id for implementation in the Automatic Get Network Status MR script’s parameter Transaction Filtering Plugin ID.

Adding Transaction Filtering Plugin ID

The administrator must add a plug-in implementation for the Transaction Filtering Plugin type.

To add Transaction Filtering Plugin ID for bulk network status:

  1. Go to Customization > Scripting > Script Deployments.

  2. Click Edit on the Automatic Get Network Status MR script.

  3. Go to Parameters subtab.

  4. In the Transactions Filtering Plugin ID field, enter the relevant ID.

  5. Click Save.

Related Topics

General Notices