2

Anyone have an answer why in client side SuiteScript 2.0, this code gives an error "Invalid transaction reference key 8355" but when I run the same call in 1.0 flavor, it works. Anyone have an idea as to why?

SuiteScript 2.0 (fails)

require(['N/record'], function(record){

    var note = record.create({type: 'note'});
    note.setValue({fieldId: 'title', value: 'Test'});
    note.setValue({fieldId: 'note', value: 'note description'});
    note.setValue({fieldId: 'notetype', value: 7});
    note.setValue({fieldId: 'transaction', value: 8355});
    note.save();
})

SuiteScript 1.0 (works)

var record = nlapiCreateRecord('note');
record.setFieldValue('title', 'Test' );
record.setFieldValue('note', 'note description');
record.setFieldValue('notetype',7 );
record.setFieldValue('transaction',8355);
var recordId = nlapiSubmitRecord(record);

The 1.0 client side SuiteScript runs fine.

Erick Smith
  • 937
  • 7
  • 27
  • 1
    I've written code almost identical to yours (no notetype) and it works fine server side. I've also seen a few odd issues with id conversion in SuiteScript. Try adding quotes around `'8355'` or try with `record.setValue({fieldId:'transaction', value:currentRecord.id});` (or load the transaction you want to add the note to and then get the id from that) – bknights Aug 10 '18 at 16:41
  • I've tried a variety of different ways including quotes, loading from currentrecord and omitting everything but title and transaction but still no go. I may file a bug with NS if this is easily reproducible for others. Thanks – Erick Smith Aug 10 '18 at 16:44
  • good luck with the bug filing. If it helps on the client side there is a script call that is attempting to get the list of available values for the transaction field and it's returning empty. This is a crazy thing for a script to have. – bknights Aug 10 '18 at 17:39

1 Answers1

2

I can confirm that I have just used your code exactly (except switching the note type and transaction fields to match my account) and it worked fine. I performed my test in the console on a sales order so it should work just fine in a client suitescript. What is the error you are receiving? I would double check that your note type and transaction values are valid. Also, what is your script deployment look like, maybe there is an issue there?

Another thing, you were missing a ')' at the end of your code block but I assume that was a copy paste error.

This works for me:

require(['N/record'], function (record) {
    var note = record.create({type: 'note'});
    note.setValue({fieldId: 'title', value: 'Test'});
    note.setValue({fieldId: 'note', value: 'note description'});
    note.setValue({fieldId: 'notetype', value: 7});
    note.setValue({fieldId: 'transaction', value: 453});
    note.save();
});
Jon Lamb
  • 1,413
  • 2
  • 16
  • 28
  • That’s interesting. I also tried to test this in a console and confirmed Erick’s results. Your code isn’t the same though. His uses note type 7. Your’s uses 5. I wonder if that’s it or if it’s one of those list lookup configuration options from set preferences. Not at a computer right now or I’d test. – bknights Aug 12 '18 at 20:52
  • Works for note type 7 for me too, I just had 5 since it was the default. These can be changed per account though which is why I asked Erick to double check the values for note type and transaction since those are the only two note values that can't be certain to be the same in my account as well. – Jon Lamb Aug 12 '18 at 23:37
  • "Invalid transaction reference key 8355" is my experience for client side SS 2.0. I can't wrap my head around the problem. It's about as basic a script as it comes. – Erick Smith Aug 15 '18 at 13:15
  • I didn't mention this, but I was in edit mode for the record. It didn't seem to matter whether it was edit or view mode though. – Erick Smith Aug 15 '18 at 13:18
  • Ill mark you as the answer. It works now but my code never changed. *shrug* – Erick Smith Oct 09 '19 at 20:13