can i set externalid to any field value on record ...
# suitescript
l
can i set externalid to any field value on record save through a script?
s
You should be able to set externalid, but remember it is a unique key and will error on collision. IIRC there's also some limitations on the characters allowed in externalid
l
ffff**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(['N/search', 'N/record', 'N/runtime', 'N/file', 'N/format', 'N/log'],
function(search, record, runtime, file, format, log) {
function beforeSubmit(context) {
var newRecord = context.newRecord;
var name = newRecord.getValue({fieldId: 'name'});
log.debug({
title: 'name',
details: name
})
newRecord.setValue({fieldId:'externalid', value: name})
}
return {
beforeSubmit: beforeSubmit,
};
});
am i doing anything wrong here?
b
Cant do it beforeSubmit
l
for some reason the field value is not changing even afterSubmit. Any idea why this is happening?
b
what does your afterSubmit code look like