[Functions] Loop not marking first line as received

Me again. When I run my loop it marks all other lines received but not the first one.

var recData = GetEFTest();

            recData.ForEach(x => {

                var item = new
                {
                    poNum = x.po_number,
                    vendorNum = x.vendor_code,
                    packSlip = x.pack_slip_num,
                    poLine = x.pack_slip_num_line
                };


                var epiResponse = EpicorRest.EfxPost("ReceiptLib", "ReceiptMass", item);

                if (epiResponse.IsErrorResponse)
                {
                    print(epiResponse.ResponseError);
                }
                else
                {
                    print($"success for poLine: {x.pack_slip_num_line}");
                    print(x.pack_slip_num_line);
                    x.interfaced = true;
                    x.interface_datetime = DateTime.Now;
                    db.SaveChanges();
                }
            });

Any idea why it would do this? I even tried setting received to true in the dataset on the function.

image

I guess a question could be. Is there a way to add all 3 lines in the loop then update the dataset with all three lines instead of running each line through all of this in the function

Are you able to manually mark the first line as received in epicor?

have you tried switching the foreach out like this (plus a few other minor tweaks:)?

var recData = GetEFTest();

foreach (var recItem in recData) {
    var item = new { poNum = recItem.po_number, vendorNum = recItem.vendor_code, packSlip = recItem.pack_slip_num, poLine = recItem.pack_slip_num_line };
    var epiResponse = EpicorRest.EfxPost("ReceiptLib", "ReceiptMass", item);

    if (epiResponse.IsErrorResponse) {
        print(epiResponse.ResponseError);
    } else {
        print($"success for poLine: {item.pack_slip_num_line}");
        print(item.pack_slip_num_line);
        recItem.interfaced = true;
        recItem.interface_datetime = DateTime.Now;
        db.SaveChanges();
    }
}

Yes without a problem. I can mark the individual line as received and received all on the header.

I have tried this sort of foreach loop as well. I also made another function just to mark the po all received and got nothing back. I also went into the dataset and marked it manually
image

Is there a way to iterate through a function for all of the lines?