I'm trying to create a Deposit record programmatic...
# suitescript
j
I'm trying to create a Deposit record programmatically when a user creates a Customer Payment to Undeposited Funds. I'm having an issue on the sublist as the recently created customer payment will not show up even if the accounts used are already the same on both Customer Payment and Deposit records. Is there something wrong with my script?
Copy code
const custpymtActualAccount = custPymtRecObj.getValue({ fieldId: 'custbody_gli20210616_actualpaymentbank' });
log.emergency({
    title: 'Customer Payment Actual Account Internal ID',
    details: custpymtActualAccount
});
const depositRecObj = record.create({
    type: record.Type.DEPOSIT,
    isDynamic: true,
    defaultValues: {
        account: custpymtActualAccount
    }
});
log.emergency({
    title: 'Defaulted Value:',
    details: {
        account: depositRecObj.getValue({ fieldId: 'account' })
    }
})

const paymentLineNumber = depositRecObj.findSublistLineWithValue({
    sublistId: 'payment',
    fieldId: 'id',
    value: custPymtRecObj.id
});

const paymentLineCount = depositRecObj.getLineCount({
    sublistId: 'payment'
});

log.emergency({
    title: 'Payment Line Number existing?',
    details: {
        paymentLineNumber,
        paymentLineCount
    }
});

const depositPaymentLineIds = [];



if (paymentLineNumber > -1) {
    depositRecObj.selectLine({
        sublistId: 'payment',
        line: paymentLineNumber
    });
    depositRecObj.setCurrentSublistValue({
        sublistId: 'payment',
        fieldId: 'deposit',
        value: true,
        ignoreFieldChange: false
    });
    depositRecObj.commitLine({
        sublistId: 'payment'
    });
} else {
    for (let paymentLineCtr = 0; paymentLineCtr < paymentLineCount; paymentLineCtr++) {
        depositRecObj.selectLine({
            sublistId: 'payment',
            line: paymentLineCtr
        });
        const currentLinePaymentId = depositRecObj.getCurrentSublistValue({
            sublistId: 'payment',
            fieldId: 'id'
        });
        depositPaymentLineIds.push(currentLinePaymentId);
        if (currentLinePaymentId === custPymtRecObj.id) {
            depositRecObj.setCurrentSublistValue({
                sublistId: 'payment',
                fieldId: 'deposit',
                value: true,
                ignoreFieldChange: false
            });
        }
    }
    log.emergency({
        title: 'Deposit Record Payment Line ids',
        details: depositPaymentLineIds
    });
}

const depositRecId = depositRecObj.save();
b
how many payment lines are there?
j
nevermind, I found something that would disable the filters. fyr: https://netsuite.custhelp.com/app/answers/detail/a_id/36723/kw/ under "Disabling Filters in SuiteScript 2.x"