I encounter issue setting a custom field on an inbound shipment not saved but if do load again it works. Is there something i missed, please let me know. TIA
t
Th3VanMan
07/27/2022, 1:41 AM
Maybe if you share a bit more information:
• context the script is running in
• sample of the the code
f
Fernz
07/29/2022, 2:13 AM
The script is a Restlet
Fernz
07/29/2022, 2:14 AM
It look up Inbound Shipment record using a container number
Fernz
07/29/2022, 2:15 AM
If found, it load the record then received it
Fernz
07/29/2022, 2:21 AM
before saving it populates a custom field
inboundShipment.setValue('custrecord_shipment_no', obj.shipmentNumber);
var id = rec.save();
log.audit('post', 'Received Inbound Shipment | id : ' + id);
I don't see any errors after saving, but the custom field never get set.
However If I reload the same record and set the custom field it works, but there are issues sometimes if the Inbound shipment is fully received it seems Netsuite put the record as read only and throw error on saving.
var inboundShipment = record.load({
type: record.Type.INBOUND_SHIPMENT,
id: result.id,
//isDynamic: true
});
nboundShipment.setValue('custrecord_shipment_no', obj.shipmentNumber);
inboundShipment.save();
t
Th3VanMan
07/29/2022, 5:28 PM
Not sure I can see your issue. But, I suspect it may be a timing issue. You have the record in Dynamic mode, and some records, Inbound Shipment may be one, need fields to be set in a particular order. You could try it in Non-dynamic mode, see if that helps the issue. When you say "reload" the record, do you mean in the script? If this is the case, I would try saving the record, then setting the custom field, and saving a second time.
f
Fernz
08/09/2022, 10:23 PM
Sorry got busy and not able read your reply right away, anyway thanks