Matt Poloni
06/26/2023, 7:26 PMbeforeLoad
UE script:
if (type == 'create'){
nlapiSetLineItemValue('recmachcustrecord_3805_dunning_recipient_cust', 'custrecord_3805_dunning_recipient_cont','1','29');
}
I translated that into SS 2.1 w/ setSublistValue
in place of nlapiSetLineItemValue
and it works fine when creating a customer in the UI, but I get an UNEXPECTED_ERROR
pointing to that method when creating a customer via CSV import. I also get the same error when using it in beforeSubmit
. (In afterSubmit
, I don't get an error, but it also requires me to load/save it explicitly, which obviously isn't available in `beforeLoad`/`beforeSubmit` when creating)
Is there some reason I'm unaware of (and can't seem to find) that explains why I can't use setSublistValue
in `beforeLoad`/`beforeSubmit` when creating customers via CSV? And are other execution contexts (e.g. SOAP/REST Web Services) going to have similar problems?Matt Poloni
06/26/2023, 8:51 PMThefunction modifies a sublist line item in a record, and it's not allowed insetSublistValue
because the record isn't fully initialized at that point in the script execution context.beforeLoad
As for why you're encountering an error while importing a CSV, it might be because thecontext also doesn't work with CSV imports as the whole file is processed as a batch operation. Hence, the record object is not fully available and is not modifiable in the same way as it is when you are creating a record in the UI.beforeSubmit
I think you can use solution for your problem a Scheduled Script or Map/Reduce script to process new customers and add the necessary Dunning Letter recipients. This would involve periodically scanning for newly created customer records and adding the required recipients.I kinda understand why NS might disallow
setSublistValue
in beforeLoad
when not in a UI context. But it still feels weird that I can't do it in beforeSubmit
, especially since I'm not relying on any data from that record or any other record (it's for all customers being created).
If some new requirement rules out my use of the afterSubmit
function, then I might go with a SS or MR.erictgrubaugh
06/26/2023, 9:05 PMXEDIT
events), and sublists are not available during inline edits. Your script could detect the CSV execution context and load the record before you modified the sublists, and you would most likely want to do that during afterSubmit
.Matt Poloni
06/27/2023, 1:52 PMXEDIT
events)", do you mean that literally? Or are you saying that it behaves the same way?
I only ask because I am logging the UE type in my script during testing and the CSV imports come in as CREATE
or EDIT
instead of XEDIT
.
Either way, this is at least a good mental model for me to keep handy. I really appreciate your help (both here and in the NS community in general).erictgrubaugh
06/27/2023, 2:37 PM