okay i know i'm missing something dumb. i have a r...
# general
j
okay i know i'm missing something dumb. i have a record that is adding lines to a sales order, and i want to get the line id that i just created and put it back on my custom record. how do i store a transaction line id after i add it to the order?
Copy code
function addLinesToSalesOrder(salesOrder, itemLines, currentRecordId) {
        itemLines.forEach(function(item) {
            salesOrder.selectNewLine({
                sublistId: 'item'
            });
            salesOrder.setCurrentSublistValue({
                sublistId: 'item',
                fieldId: 'item',
                value: item.itemId
            });
            salesOrder.setCurrentSublistValue({
                sublistId: 'item',
                fieldId: 'quantity',
                value: item.quantity
            });
            salesOrder.setCurrentSublistValue({
                sublistId: 'item',
                fieldId: 'rate',
                value: item.rate
            });
            salesOrder.commitLine({
                sublistId: 'item'
            });
            var lineId = salesOrder.getSublistValue({
                sublistId: 'item',
                fieldId: 'line'
            });
    
            // Create a custom record for each line added
            createCustomRecord(currentRecordId, lineId, item.itemId, item.quantity);
        });
    }
b
you need to save the sales order before getting the id
ids are generated after save, not before
j
i thought they stored after committing. so i need to save the SO and then loop through the lines i just created? so i'm going to need to link it back to the custom record so i know what id to grab. is there a more efficient way of doing that?
b
you will need to do a search/query or at worst a record load to get the ids after you do your save
they wont get updated on the record you submitted
j
yeah i did that and it works, just hope it doesn't slow things down too much at volume. thanks
b
you want the search or query if doing multiple record
mostly because you can search/query for multiple records at a time
☝️ 1