Luiz Anjos
07/23/2019, 5:13 AMnzy
07/23/2019, 5:18 AMLuiz Anjos
07/23/2019, 5:25 AMconst setRecordValue = (fieldId : Record, value: FieldValue) => {
record.setValue({fieldId: fieldId, value: value});
}
const inventoryAdjustmentRec: Record = create({
type: Type.INVENTORY_ADJUSTMENT,
isDynamic: false,
});
setRecordValue(inventoryAdjustmentRec, 'custom_form', inventoryAdjustment.custom_form_id);
setRecordValue(inventoryAdjustmentRec, 'tran_date', inventoryAdjustment.transaction_date);
setRecordValue(inventoryAdjustmentRec, 'subsidiary', inventoryAdjustment.subsidiary_id);
setRecordValue(inventoryAdjustmentRec, 'account', inventoryAdjustment.account_id);
setRecordValue(inventoryAdjustmentRec, 'memo', inventoryAdjustment.memo);
inventoryAdjustment.inventory_list.forEach(function (inventoryListItem: InventoryListItem, index: number) {
inventoryAdjustmentRec.setSublistValue({
sublistId: 'inventory',
fieldId: 'item',
line: index,
value: inventoryListItem.item_id
});
inventoryAdjustmentRec.setSublistValue({
sublistId: 'inventory',
fieldId: 'adjustqtyby',
line: index,
value: inventoryListItem.adjust_qty_by
});
inventoryAdjustmentRec.setSublistValue({
sublistId: 'inventory',
fieldId: 'location',
line: index,
value: inventoryListItem.location_id
});
inventoryAdjustmentRec.setSublistValue({
sublistId: 'inventory',
fieldId: 'unit_cost',
line: index,
value: inventoryListItem.unit_cost
});
let inventoryDetail : Record = inventoryAdjustmentRec.getSublistSubrecord({
sublistId: 'inventory',
fieldId: 'inventorydetail',
line: index
});
inventoryDetail.setSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'issueinventorynumber',
line: index,
value: '1'
});
inventoryDetail.setSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
line: index,
value: inventoryListItem.adjust_qty_by
});
});
inventoryAdjustmentRec.save({
enableSourcing: true,
ignoreMandatoryFields: false,
});
nzy
07/23/2019, 5:32 AMlog.debug
to check the valuesLuiz Anjos
07/23/2019, 5:48 AMnzy
07/23/2019, 5:50 AM