Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified: schedule suitescript and added code to count script usages unit. (177-convert-customer-deposit-flow-from-schedule-to-mapreduce) #178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/FileCabinet/SuiteScripts/CashSale/HC_SC_ImportCashSale.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, task, error, search, file) {
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file', 'N/runtime'], function (sftp, task, error, search, file, runtime) {
function execute(context) {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

//Get Custom Record Type SFTP details
var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -68,6 +71,11 @@ define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, ta
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
var fileName = null;

Expand Down
10 changes: 9 additions & 1 deletion src/FileCabinet/SuiteScripts/Customer/HC_SC_ImportCustomer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, task, error, search, file) {
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file', 'N/runtime'], function (sftp, task, error, search, file, runtime) {
function execute(context) {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

// Establish a connection to a remote FTP server
/* The host key can be obtained using OpenSSH's ssh-keyscan tool:
ssh-keyscan -t <hostKeyType> -p <port> <hostDomain>
Expand Down Expand Up @@ -74,6 +77,11 @@ define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, ta
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
var fileName = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, task, error, search, file) {
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file', 'N/runtime'], function (sftp, task, error, search, file, runtime) {
function execute(context) {
try {
// Establish a connection to a remote FTP server
/* The host key can be obtained using OpenSSH's ssh-keyscan tool:
ssh-keyscan -t <hostKeyType> -p <port> <hostDomain>
Example: ssh-keyscan -t ECDSA -p 235 hc-uat.hotwax.io
*/
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -73,6 +70,11 @@ define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, ta
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
var fileName = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, task, error, search, file) {
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file', 'N/runtime'], function (sftp, task, error, search, file, runtime) {
function execute(context) {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
columns: [
Expand Down Expand Up @@ -67,6 +70,11 @@ define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, ta
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
var fileName = null;
try {
Expand Down
10 changes: 9 additions & 1 deletion src/FileCabinet/SuiteScripts/POSReturn/HC_SC_CreatePOSReturn.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
* @NScriptType ScheduledScript
*/

define(['N/sftp', 'N/record', 'N/error', 'N/search', 'N/file'], function (sftp, record, error, search, file) {
define(['N/sftp', 'N/record', 'N/error', 'N/search', 'N/file', 'N/runtime'], function (sftp, record, error, search, file, runtime) {

function execute(context) {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

// Establish a connection to a remote FTP server
var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -69,6 +72,11 @@ define(['N/sftp', 'N/record', 'N/error', 'N/search', 'N/file'], function (sftp,
});

for (var i = 0; i < list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
var fileName = list[i].name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search, record, error, sftp, file) {
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file', 'N/runtime'], function (search, record, error, sftp, file, runtime) {
function execute(context) {
try {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

//Get Custom Record Type SFTP details
var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -68,6 +71,11 @@ define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
try {
var fileName = list[i].name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search, record, error, sftp, file) {
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file', 'N/runtime'], function (search, record, error, sftp, file, runtime) {
function execute(context) {
try {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

//Get Custom Record Type SFTP details
var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -68,6 +71,11 @@ define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
try {
var fileName = list[i].name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search, record, error, sftp, file) {
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file', 'N/runtime'], function (search, record, error, sftp, file, runtime) {
function execute(context) {
try {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

//Get Custom Record Type SFTP details
var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -68,6 +71,11 @@ define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
try {
var fileName = list[i].name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search, record, error, sftp, file) {
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file', 'N/runtime'], function (search, record, error, sftp, file, runtime) {
function execute(context) {
try {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

//Get Custom Record Type SFTP details
var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -68,6 +71,11 @@ define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
try {
var fileName = list[i].name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, task, error, search, file) {
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file', 'N/runtime'], function (sftp, task, error, search, file, runtime) {
function execute(context) {
try {
// Establish a connection to a remote FTP server
/* The host key can be obtained using OpenSSH's ssh-keyscan tool:
ssh-keyscan -t <hostKeyType> -p <port> <hostDomain>
Example: ssh-keyscan -t ECDSA -p 235 hc-uat.hotwax.io
*/
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

//Get Custom Record Type SFTP details
var customRecordSFTPSearch = search.create({
Expand Down Expand Up @@ -74,6 +71,11 @@ define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, ta
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
var fileName = null;
try {
Expand Down
14 changes: 8 additions & 6 deletions src/FileCabinet/SuiteScripts/SalesOrder/HC_importSalesOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, task, error, search, file) {
define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file', 'N/runtime'], function (sftp, task, error, search, file, runtime) {
function execute(context) {
try {
// Establish a connection to a remote FTP server
/* The host key can be obtained using OpenSSH's ssh-keyscan tool:
ssh-keyscan -t <hostKeyType> -p <port> <hostDomain>
Example: ssh-keyscan -t ECDSA -p 235 hc-uat.hotwax.io
*/
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

//Get Custom Record Type SFTP details
var customRecordSFTPSearch = search.create({
Expand Down Expand Up @@ -74,6 +71,11 @@ define(['N/sftp', 'N/task', 'N/error', 'N/search', 'N/file'], function (sftp, ta
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}

if (!list[i].directory) {
var fileName = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
* @NScriptType ScheduledScript
*/

define(['N/sftp', 'N/record', 'N/error', 'N/search', 'N/file'], function (sftp, record, error, search, file) {
define(['N/sftp', 'N/record', 'N/error', 'N/search', 'N/file', 'N/runtime'], function (sftp, record, error, search, file, runtime) {

function execute(context) {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

// Establish a connection to a remote FTP server
var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -71,6 +74,10 @@ define(['N/sftp', 'N/record', 'N/error', 'N/search', 'N/file'], function (sftp,

for (var i = 0; i < list.length; i++) {
if (!list[i].directory) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}
var fileName = list[i].name;

// Download the file from the remote server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search, record, error, sftp, file) {
define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file', 'N/runtime'], function (search, record, error, sftp, file, runtime) {
function execute(context) {
try {
try {
var usageThreshold = 500; // Set a threshold for remaining usage units
var scriptObj = runtime.getCurrentScript();

//Get Custom Record Type SFTP details
var customRecordSFTPSearch = search.create({
type: 'customrecord_ns_sftp_configuration',
Expand Down Expand Up @@ -68,6 +71,10 @@ define(['N/search', 'N/record', 'N/error', 'N/sftp', 'N/file'], function (search
});

for (var i=0; i<list.length; i++) {
if (scriptObj.getRemainingUsage() < usageThreshold) {
log.debug('Scheduled script has exceeded the usage unit threshold.');
return;
}
if (!list[i].directory) {
try {
var fileName = list[i].name;
Expand Down