Can't create note record in Suitescript 2.0 but can in 1.0

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Can't create note record in Suitescript 2.0 but can in 1.0



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.





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 at 16:41



'8355'


record.setValue(fieldId:'transaction', value:currentRecord.id);





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 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 at 17:39




1 Answer
1



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();
);





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 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 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 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 at 13:18






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS