Hi everyone, I’m trying to validate Item save to m...
# suitescript
g
Hi everyone, I’m trying to validate Item save to make sure that vendors sublist pruchase price is set so I’m using Client Script saveRecord method. In that, I return false if its not set and true if it is. The problem is, that if I edit the record and trigger save without the price set, edit the vendor sublist, add price and re-save again, I get “There is already an item with that name” error on the next page. At this point, I have no idea why. Code: What am I doing wrong?
b
You probably dont want to commit the line if you arent going to make any changes
g
I removed that part and still the same 😞
b
there are mechanics around automatically creating the subrecord
g
I’m not creating subrecords, I just want to see if the itemvendorprice has any rows set
b
use hasCurrentSublistSubrecord to determine if the subrecord exists before using getCurrentSublistSubrecord to create it
g
Just tried that, same error:
Copy code
if (itemRecord.hasCurrentSublistSubrecord({sublistId: 'itemvendor', fieldId: 'itemvendorprice'})) {
                var sublistRecord = itemRecord.getCurrentSublistSubrecord({
                    sublistId: 'itemvendor',
                    fieldId: 'itemvendorprice'
                });

                var sublistSubRecordCount = sublistRecord.getLineCount({
                    sublistId: 'itemvendorpricelines'
                });
            } else {
                var sublistSubRecordCount = 0;
            }

            if (sublistSubRecordCount > 0) {
                isPriceSet = true;
                break;
            }
b
is this error happening in the browser clientside
or is it happening after it has been saved serverside
g
after. Serverside
b
probably want to make sure it isnt an error caused by any other user event scripts or workflows
im not able to reproduce your problem
g
This is standard NS duplication error message, is it not?
b
it is, but that doesn't mean it cant be caused by scripts
g
it looks like the problem lies with how this is being tested.
I checked UserEvent scripts (only few existing), none does anything with items
b
usually you check by using Scripted Records