What is the proper syntax to create a BANK Deposit...
# suitescript
j
What is the proper syntax to create a BANK Deposit record? I can add cashback just fine but when I go to add payments it seems impossible. Nothing works. Either invalid sublist operation or the record will perpetually be changed every time I try to save and fail to save. I tried:
Copy code
depositRecord.selectNewLine({ sublistId: 'payment' });
Result: SSS_INVALID_SUBLIST_OPERATION I think works but causes perpetual "Record changed" error:
Copy code
depositRecord.selectLine({
                                sublistId: 'payment',
                                line: i
                            });
a
those lines of code are fine if they're in the right place but you haven't provided enough context. For us to know what's happening. are you using the currentRecord or record module? is the record in dynamic or standard mode? are you in a client context or serverside?
record changed error is annoying, first thing would be to check any client/UE and workflow scripts on the record that my be also trying to change things based on your change the invalid sublist op is most likely because you're using the record module in standard mode... and that method if only available in dynamic mode
j
I finally figured out how to do it. I have to be in standard mode and fine the line number for the payment to apply.
Copy code
var lineNumber = depositRecord.findSublistLineWithValue({
                                sublistId: 'payment',
                                fieldId: 'id',
                                value: relTransId
                            });
                            log.debug({
                                title: "lineNumber for " + relTransId,
                                details: lineNumber
                            });
                            depositRecord.setSublistValue({
                                sublistId: 'payment',
                                fieldId: 'id',
                                line: lineNumber,
                                value: relTransId,
                            });
                            depositRecord.setSublistValue({
                                sublistId: 'payment',
                                fieldId: 'deposit',
                                line: lineNumber,
                                value: true,
                            });
Now I am having an issue with setting the correct date. The date is formatted with
Copy code
formattedDate = format.format({
                    value: new Date(disbursementDate), // Assuming disbursementDate is in a valid date format
                    type: format.Type.DATE
                });
Debug Log: 8/10/2023 Error:
Copy code
"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"Invalid date value (must be M/D/YYYY)"
Nevermind, formatting was not required, I just had to set the date as a date object.
👍 1