Can anyone tell me what went wrong with this? Not ...
# suitescript
k
Can anyone tell me what went wrong with this? Not really a developer - just trying to use a suite answers article without having to hand type all the names. I know the issue is with my var "sub" and how i'm trying to set it -because it works without it - just not seeing what I did wrong.
Copy code
(function changeId(){

require(['N/record', 'N/currentRecord'],
function(record, currRec) {
  var rec = currRec.get()

  var rec = record.load({
  type: record.Type.SUBSIDIARY,
  id: rec.id
});
  var sub = rec.getValue({
  fieldID: 'name'});
  
   rec.setValue({
  fieldId: 'externalid',
  value: sub
});

rec.save();

});
}())
b
fieldID vs fieldId
general warning about saving the current record means that all the current work done on the record will be lost since the record has been changed
k
which is fine - i'm running this in console to set the external ID on the sub
That did it.
Thanks.
The copy/paste of the name 45 times was getting old
b
most would have done a csv import'
k
Can't do a CSV import to set external ID on subsidiaries.
b
that is an uninspired article
k
I didn't write it (shrug)
b
there is no real need to go to every subsidiary to make that change
k
I'm sure a more efficient script could be written.
Problem is these folks have insane hierarchy - and I don't feel like doing vlookups to get internal IDs anymore for saved CSV imports.
m
nlapiSubmitField('subsidiary', subsidiaryInternalID, 'externalid', 'subsidiaryExternalId');
FYI you can do this with a single line of SS1 on the console
I've done this for adhoc "mass updates" using a formula to in excel to concatenate the script. You can run about 200 at a time until you need to refresh the page to restart governance limits