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();
Rookie Asked on November 23, 2021 in SuiteScript.
Add Comment
2 Answer(s)

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
Hello,
i use this code and i have no problems

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

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

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

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

var line = itemFulfillment.getSublistValue({
sublistId:’item’, // nome della sublist
fieldId:’line’, // nome del campo
line:i
});

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

}

itemFulfillment.save()

ciao

Mauro

 

 
Rookie Answered on January 27, 2022.

This gives me the same issue. Note, I have the auto-fulfill feature disabled. Performing any “setSubListValue” or “setCurrentSublistValue” results in the same “field.getSublistName is not a function”

on May 12, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor