Luis
06/18/2023, 12:17 AMLuis
06/18/2023, 12:19 AM/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/search'], function(search) {
function beforeSubmit(context) {
if (context.type === context.UserEventType.CREATE || context.type === context.UserEventType.EDIT) {
var newRecord = context.newRecord;
var uniqueId = newRecord.getValue({
fieldId: 'name'
});
var filters = [
search.createFilter({
name: 'name',
operator: <http://search.Operator.IS|search.Operator.IS>,
values: uniqueId
})
];
var existingId = search.create({
type: 'customrecord_abc_container',
filters: filters
}).run().getRange({
start: 0,
end: 1
});
// Check if any existing records were found
if (existingId.length > 0) {
throw new Error('The record already exists.');
}
}
}
return {
beforeSubmit: beforeSubmit
};
});
Anthony OConnor
06/18/2023, 12:29 AMAnthony OConnor
06/18/2023, 12:31 AMLuis
06/18/2023, 12:35 AMLuis
06/18/2023, 12:37 AMAnthony OConnor
06/18/2023, 12:37 AMAnthony OConnor
06/18/2023, 12:37 AMLuis
06/18/2023, 12:40 AMAnthony OConnor
06/18/2023, 12:41 AMAnthony OConnor
06/18/2023, 12:42 AMexternalId
isn't the solution hereLuis
06/18/2023, 12:46 AMbattk
06/18/2023, 1:46 AMbattk
06/18/2023, 1:51 AMLuis
06/18/2023, 6:43 AMbattk
06/18/2023, 6:48 AMbattk
06/18/2023, 6:48 AMbattk
06/18/2023, 6:48 AMbattk
06/18/2023, 6:48 AMLuis
06/29/2023, 5:31 PM