tuli
11/21/2024, 2:17 PMCeligo AI
11/21/2024, 2:18 PMAI generated answer (using internal Slack threads):Based on the conversations, it seems like you are trying to set the
externalid
field in the beforeSubmit
event. However, the externalid
field cannot be set in the beforeSubmit
event. This is because the beforeSubmit
event occurs before the record has been saved, and any modifications to the record in this event can cause a record modification error since the original is now out of sync.
Instead, you should set the externalid
field in the afterSubmit
event. Here is a sample code snippet:
javascript
define(['N/record', 'N/log'],
function(record, log) {
function afterSubmit(context){
var itemRecord = context.newRecord;
var itemField = itemRecord.getValue({ fieldId: 'cust_field_reference_i_triple_checked_is_correct'});
if(itemField){
record.submitFields({
type: record.Type.NON_INVENTORY_ITEM,
id: itemRecord.id,
values: {
externalid: itemField
}
});
log.audit({title: 'Set External ID of ' + itemRecord});
}
}
return {
afterSubmit: afterSubmit
};
});
In this code, the externalid
field is set in the afterSubmit
event using the submitFields
method. The externalid
is set to the value of the custom field cust_field_reference_i_triple_checked_is_correct
.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
11/21/2024, 2:18 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.860393584
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858570158
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.856984735
Celigo AI
11/21/2024, 2:18 PMtuli
11/21/2024, 2:21 PM