Created
February 11, 2022 16:32
-
-
Save marwan-nwh/2dd4e5f776a231a8ca44bdf352792903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*@NApiVersion 2.1 | |
*@NScriptType ScheduledScript | |
*/ | |
define(["N/record", "N/search"], function (record, search) { | |
function execute(context) { | |
try { | |
let results = search.load({ | |
id: "customsearch_test_ae_shipment", | |
}).run().getRange(0, 100); | |
for (let i = 0; i < results.length; i++) { | |
let shipment = record.load({ | |
type: "customrecord_ae_shipment", | |
id: results[i].id, | |
}) | |
checkCountry(shipment); | |
} | |
function checkCountry(result){ | |
let countryID = result.getValue("custrecord_country"); | |
if (countryID == 1) { | |
result.setValue("custrecord_capital", 1); | |
log.audit("success", "Cairo is the capital"); | |
} | |
if (countryID == 2) { | |
result.setValue("custrecord_capital", 2); | |
log.audit("success", "London is the capital"); | |
} | |
if (countryID == 3) { | |
result.setValue("custrecord_capital", 3); | |
log.audit("success", "Washington is the capital"); | |
} | |
result.save(); | |
} | |
} catch (e) { | |
log.audit("error", e); | |
} | |
} | |
return { | |
execute: execute, | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment