Is there a way to match a line on an Item fulfillm...
# suitescript
s
Is there a way to match a line on an Item fulfillment with that of the created from (sales order)? The sys_id keeps changing so it's not matching up.
j
Yes, there is an orderline property on the lines of the item fulfillment
This corresponds to the line id of the sales order
s
The orderline was unobtainable with getSublistValue. at least it was coming back empty
j
Are you trying to access it on create or edit?
s
edit
j
Odd
I've used it successfully in the past on a number of occasions
s
It's in an afterSubmit. I was able to re-load the IF and it just started working
👍 1
Nvm, it's not working still. Stupid! I'm loading the SO, I'm loading the IF, and the sys ids are still different in code
j
Happy to take another look if you have code snippets / logs to review. I've struggled with this myself so I feel your pain haha
s
Thanks @Jan Petri
Copy code
{
    const salesOrd =record.load({
            id: createdFrom,
            type: record.Type.SALES_ORDER,
            isDynamic: false
        });
     newRec = record.load({
        id: newRec.id,
        type: record.Type.ITEM_FULFILLMENT,
        isDynamic: false
     });
logIds(newRec, salesOrd, 1)
}
function logIds(newRec, salesOrd, seq) {
        const lineSysIds = [];
        const lineSysIdsSOs = [];
        if (newRec) {
            const cnt = newRec.getLineCount('item');
            for (let i = 0; i < cnt; i++) {
                lineSysIds.push(newRec.getSublistValue({ sublistId: 'item', fieldId: 'sys_id', line: i }));
            }
        }
        if (salesOrd) {
            const cntSO = salesOrd.getLineCount('item');
            for (let i = 0; i < cntSO; i++) {
                lineSysIdsSOs.push(salesOrd.getSublistValue({ sublistId: 'item', fieldId: 'sys_id', line: i }));
            }
        }
        if (!seq) {
            seq = 0;
        }
        log.debug('grr' + seq, { lineSysIds, lineSysIdsSOs });
    }
Copy code
{
   lineSysIds: [
      "7549829923287858"
   ],
   lineSysIdsSOs: [
      "7549829432570145",
      "7549829432252979"
   ]
}
As you can see, the sys_ids are off
j
Is there a reason you're using sys_id as opposed to the "line" and "orderline"? So on the SO you could use fieldId "line" and on the IF you could use fieldId "orderline". At least that's what I've used to match lines between SO and IF
s
I just switched to lines. I thought sys_id would be much better, but they change
earlier, when I looked at orderline I should of already taken a break. It's orderline on IF and line on SO 🤦🏼‍♂️
j
Been there done that haha
😆 1
m
Eventually all these fun NS Application oddness gets forever burnt into your memory.
259 Views