When Transfer Order is in ‘Received’ status, the Close Order button still appears on the record as even though the transaction is completed there are still open items on the order, but when the button is pressed, nothing will happen since for NetSuite it appears that the transaction is already completed.
The Close Order button removed for Transfer Orders which are in ‘Received’ status to avoid any confusion but in order to get the order to ‘Closed’ status, one would have to manually edit the order, mark the line items to closed, and save it in order for it to be fully closed.
The script below that returns the Transfer Order and then closes it accordingly.
var rec = record.load({
type: record.Type.TRANSFER_ORDER,
id: '12345',
});
var status = rec.getValue({ fieldId: 'status'});
log.debug('status', status)
if (status == 'Received') {
var count = rec.getLineCount({sublistId: 'item'});
for (var i = 1; i <= count; i++) {
var isclosed = rec.getSublistValue({
sublistId: 'item',
fieldId: 'isclosed',
line: i
});
log.debug('status', status);
if (isclosed == 'F') {
rec.selectLine({
sublistId: 'item',
line: i
});
rec.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'isclosed',
value: 'T',
});
rec.commitLine({ sublistId: 'item'});
}
}
}