NetSuite SuiteScript - 创建存款

问题描述 投票:0回答:1

我有一个 Suitescript 来创建存款。除了最近的一个之外,它在我部署过的几个 NetSuite 帐户中运行良好。它返回以下错误:

USER_ERROR 请输入以下值:部门、班级

这是脚本示例:

const rec = record.create({
    type: record.Type.DEPOSIT,
    isDynamic: true,
    defaultValues: {
        account: 1232,
    },
});

rec.setValue('trandate', new Date('01/29/2024'));

const additionalFields = [
    {'fieldId': 'department', 'fieldValue': '110'},
    {'fieldId': 'class', 'fieldValue': '201'}
]

if (additionalFields) {
    log.debug('info', 'setting additional fields');
    for (const x of additionalFields) {
        log.debug('set field', x.fieldId + ': ' + x.fieldValue);
        rec.setValue(x.fieldId, x.fieldValue);
    }
}

const applyPayments = ['575126']
if (applyPayments) {
    for (const x of applyPayments) {
        log.debug('lookup payment', x);
        const index = rec.findSublistLineWithValue({
            sublistId: 'payment',
            fieldId: 'id',
            value: x,
        });
        log.debug('payment', index);

        if (index == -1) {
            result = {
                error: {
                    code: 'NOT_FOUND',
                    detail: 'ID for supplied payment does not exist!',
                },
            };
            return result;
        } else {
            rec.selectLine({
                sublistId: 'payment',
                line: index,
            });

            rec.setCurrentSublistValue({
                sublistId: 'payment',
                fieldId: 'deposit',
                value: true,
            });

            rec.commitLine({sublistId: 'payment'});
        }
    }
}

newRecordId = rec.save();

如您所见,我确实设置了部门和班级,但不知何故它没有被识别。 用户界面如下所示:

任何帮助将不胜感激。

netsuite suitescript
1个回答
0
投票

如果您使用的部门和类别允许交易子公司使用,那么该账户可能还需要行级别的部门和类别。

© www.soinside.com 2019 - 2024. All rights reserved.