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:
-
The Network Reference Id is populated.
-
The Network Status Updated On date is either on the current or previous day.
-
The transaction's e-document status is not Canceled.
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:
-
The Network Reference Id is populated.
-
The Network Status Updated On date is either on the current or previous day.
-
The transaction's e-document status is not Canceled.
/**
* @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:
-
Go to Customization > Scripting > Script Deployments.
-
Click Edit on the Automatic Get Network Status MR script.
-
Go to Parameters subtab.
-
In the Transactions Filtering Plugin ID field, enter the relevant ID.
-
Click Save.
Related Topics
- Electronic Invoicing Administrator Guide
- Installing and Setting Up Electronic Invoicing
- Defining the E-Document Country for Free Use
- Advanced PDF/HTML Template
- Granting Access Permission to the E-Documents Portlet
- Understanding E-Documents and E-Document Packages
- Creating E-Document Packages
- Multi-subsidiary Support in the Outbound Process
- Creating E-Document Templates
- Editing E-Document Templates
- E-Document Certification in the Outbound Process
- E-Document Network Status Overview
- Creating E-Document Sending Methods
- E-Document Email Custom Templates
- Selecting a Designated E-Document Sender
- Setting Up Custom Roles to Send E-Documents
- Customizing Roles to Restrict E-Document Generation or Sending
- Deploying the Bulk Generation Script for E-Documents
- Deploying the Script for Bulk Scheduled Sending of E-Documents
- Updating E-Document Certification Statuses
- Processing E-Documents Automatically for Individual Transactions
- Electronic Invoicing Inbound Email Capture
- Using SOAP Web Services for Inbound Processing
- Setting Up Custom Roles that can Convert Inbound E-Documents
- Inbound Validation Plug-ins
- Deploying Automatic Bulk Conversion Script for Inbound E-Documents