``` try { newRe...
# suitescript
c
Copy code
try {
                    newRecord.setText('shipmentStatus', 'In Transit');
                    log.debug('Status set');
                } catch (e) {
                    throw e;
                    log.debug('Cannot set', e);
                }
The field name is incorrect but there is no error in the logs. there isn't even a log from the catch. I would expect setting a value to an incorrect field name would throw an error.
Maybe not?
Or would an incorrect field name count as undefined?
e
Incorrect isn't undefined. It'll just silently fail
ā˜ļø 1
c
That kind of sucks
If it throws an error, that can be caught and logged at least.
In a perfect world, all field names would be available as some sort of ENUM. Having unvalidated strings floating around just asks for mistakes to be made, especially in larger codebases.
a
Try to avoid using setText...
c
Yeah, I have inherited a very large number of scripts. This is part of my review.
I've brought in coding standards which force the use of the internal ID in setValue()
a
umm set anything doesn't throw an error does it? I doubt you'd get an error till you tried to save the record and write to db anyway
I'd never wrap a setX inside a try catch
c
@Anthony OConnor above that try is this beauty of a comment // defensive try
šŸ˜‚
a
facepalm
c
To be fair to the dev that wrote this, I can't find the list/internal IDs for this field either. It's the shipmentstatus on the Inbound Shipment record which is a SuiteApp from NetSuite.
I guess they thought a setText was a quicker option to delivering something.
a
• toBeShipped • inTransit
c
Where did you find those?
a
RE/TE (reverse engineering/trial and error)
c
Fair enough.
m
Inbound Shipments aren't really a 'record' in the traditional NetSuite sense. They're kind of a record/list hybrid. A right royal pain to work with.
šŸ’Æ 1