Marwan
10/12/2023, 2:11 AMsearch.create({
type: "transaction",
filters: [
["type", "anyof", "CustDep"],
"AND",
["internalid", "anyof", "3149"],
],
columns: [
"amountpaid",
],
})
The result of the search in the scheduled have value for amountpaid
but in the UserEvent, it doesn't.Tyn Guardian
10/12/2023, 8:02 AMMarwan
10/12/2023, 8:02 AMTyn Guardian
10/12/2023, 8:03 AMMarwan
10/12/2023, 8:04 AMTyn Guardian
10/12/2023, 8:05 AMMarwan
10/12/2023, 8:06 AM/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define([
"N/record",
"N/search",
"N/runtime",
"N/task",
], function (record, search, runtime, task) {
function execute(context) {
let script = runtime.getCurrentScript();
search.create({
type: "transaction",
filters: [
["type", "anyof", "CustDep"],
"AND",
["internalid", "anyof", "3149"],
],
columns: [
"amountpaid",
],
}).run().each(function (result) {
if (script.getRemainingUsage() < 100) {
task
.create({
taskType: task.TaskType.SCHEDULED_SCRIPT,
scriptId: runtime.getCurrentScript().id,
deploymentId: runtime.getCurrentScript().deploymentId,
})
.submit();
return false;
}
let amountpaid = result.getValue("amountpaid");
log.debug("amountpaid", amountpaid);
return true;
});
}
return {
execute: execute,
};
});
ScheduledMarwan
10/12/2023, 8:07 AM/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(["N/search", "N/record"], function (
search,
record
) {
function beforeSubmit(context) {
try {
search.create({
type: "transaction",
filters: [
["type", "anyof", "CustDep"],
"AND",
["internalid", "anyof", "3149"],
],
columns: [
"amountpaid",
],
}).run().each(function (result) {
let amountpaid = result.getValue("amountpaid");
log.debug("amountpaid", amountpaid);
return false;
});
} catch (err) {
log.debug("ERROR", err);
}
}
return {beforeSubmit};
});
UserEventMarwan
10/12/2023, 8:08 AMMarwan
10/12/2023, 8:11 AMMarwan
10/12/2023, 8:12 AMTyn Guardian
10/12/2023, 8:21 AMMarwan
10/12/2023, 8:21 AM{"recordType":"customerdeposit","id":"3149","values":{"amountpaid":".00"}}
Tyn Guardian
10/12/2023, 8:26 AMMarwan
10/12/2023, 8:42 AMMarwan
10/12/2023, 11:10 AMlet resultSet = query.runSuiteQL({
query:
"SELECT foreignpaymentamountunused FROM transaction WHERE id = '" + context.newRecord.id + "' AND type = 'CustDep'",
});