Tom
08/25/2025, 1:15 PMChris
08/26/2025, 12:58 PMTom
08/26/2025, 2:44 PMTom
08/26/2025, 2:44 PMChris
08/26/2025, 2:45 PMTom
08/26/2025, 2:46 PMChris
08/26/2025, 2:50 PM/**
* @NApiVersion 2.x
* @NModuleScope Public
*/
define([
'N/log',
'N/search',
'N/runtime'],
function (
log,
search,
runtime) {
"use strict";
return {
service: function (ctx) {
var request = ctx.request;
try {
const user = runtime.getCurrentUser();
log.debug('user', user);
// if there is no userId then nobody is logged in
if (!user.id) return;
const params = JSON.parse(ctx.request.body);
log.debug("params", params);
ctx.response.setHeader('Content-Type', 'application/json');
var soid = params.soid;
if (!soid) {
log.debug("soid not found", request.parameters);
return ctx.response.write(JSON.stringify({ success: false }));
}
var salesOrderId = null;
search.create({
type: "salesorder",
filters:
[
["type", "anyof", "SalesOrd"],
"AND",
["numbertext", "is", soid],
"AND",
["mainline", "is", "T"]
],
columns:
[
"internalid"
]
}).run().each(function (r) {
salesOrderId = parseInt(r.id);
return true;
});
if (salesOrderId) {
// ... do something with it here
}
return ctx.response.write(JSON.stringify({ success: true }));
}
catch (ex) {
log.error("Error in Backend Model", ex);
return ctx.response.write(JSON.stringify({ success: false }));
}
}
};
});
Chris
08/26/2025, 2:50 PMTom
08/26/2025, 2:51 PMTom
08/26/2025, 2:52 PM/api/items
and I need to customize itChris
08/26/2025, 2:52 PM/api/items
endpoint isn't customizable.Tom
08/26/2025, 2:53 PMChris
08/26/2025, 2:54 PMTom
08/26/2025, 2:54 PMapi/items
?Chris
08/26/2025, 2:55 PMChris
08/26/2025, 2:55 PMChris
08/26/2025, 2:56 PMN/https
module.Chris
08/26/2025, 2:56 PMrequest
and response
objects to do what you want with.Tom
08/26/2025, 2:57 PM