RE: Why do I get “field.getSublistName is not a function” when setting a sublist value?

I’m trying to transform a sales order to an item fulfillment using a SS 2.0 button event handler. As simple as possible. Not trying to do anything complicated. Surely something that has been done thousands of times before.

I get error “field.getSublistName is not a function” on the line after the todo:

var itemFulfillment = record.transform({
    fromType: record.Type.SALES_ORDER,
    fromId: salesOrderId,
    toType: record.Type.ITEM_FULFILLMENT,
    isDynamic: true
});

var lineCount = itemFulfillment.getLineCount({
    sublistId: 'item'
});

log.debug({
    title: FUNCTION_NAME,
    details: {
        lineCount: lineCount
    }
});

for (var i = 0; i < lineCount; i++) {

    itemFulfillment.selectLine({
        sublistId: 'item',
        line: i
    });

    log.debug({
        title: FUNCTION_NAME,
        details: '1'
    });

    //todo error on next time: field.getSublistName is not a function

    itemFulfillment.setCurrentSublistValue({
        sublistId: 'item',
        fieldId: 'itemreceive',
        value: true
    });

    log.debug({
        title: FUNCTION_NAME,
        details: '2'
    });

    itemFulfillment.commitLine({
        sublistId: 'item'
    });
}

log.debug({
    title: FUNCTION_NAME,
    details: '3'
});

const id = itemFulfillment.save();

 

If I try in non-dynamic mode then I get the same error:

var itemFulfillment = record.transform({
    fromType: record.Type.SALES_ORDER,
    fromId: salesOrderId,
    toType: record.Type.ITEM_FULFILLMENT
});

var lineCount = itemFulfillment.getLineCount({
    sublistId: 'item'
});

log.debug({
    title: FUNCTION_NAME,
    details: {
        lineCount: lineCount
    }
});

for (var i = 0; i < lineCount; i++) {

    log.debug({
        title: FUNCTION_NAME,
        details: '1'
    });

    //todo error on next time: field.getSublistName is not a function

    itemFulfillment.setSublistValue({
        sublistId: 'item',
        line: i,
        fieldId: 'itemreceive',
        value: true
    });

    log.debug({
        title: FUNCTION_NAME,
        details: '2'
    });
}

log.debug({
    title: FUNCTION_NAME,
    details: '3'
});

const id = itemFulfillment.save();
cja Rookie Asked on November 23, 2021 in SuiteScript.
Add Comment
1 Answers

Is it possible that you have another script on the IF that is causing this?

If not, could you please share your full script(s)?

Thanks,

Chris

Intermediate Answered on November 24, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.