eagle28
eagle28

Reputation: 940

NetSuite SuiteScript - create Deposit

I have a Suitescript to create a Deposit. It works well in several NetSuite accounts where I have deployed it except for the most recent one. It returns the following error:

USER_ERROR Please enter value(s) for: Department, Class

This is the sample of the script:

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();

As you can see, I do set the Department and Class but somehow it is not recognized. This is what the UI looks like: enter image description here

Any help would be greatly appreciated.

Upvotes: 0

Views: 359

Answers (1)

bknights
bknights

Reputation: 15367

If the department and class you are using are allowed for the transaction's subsidiary then it's likely that the account also requires department and class at the line level.

Upvotes: 1

Related Questions