We're getting an unexpected error in aftersubmit f...
# suitescript
a
We're getting an unexpected error in aftersubmit function of a User Event script deployed to Invoices, but only for some users and not others. Error occurs on this line: let fileObj = render.transaction({ entityId: scriptContext.newRecord.id, printMode: render.PrintMode.PDF }); It only occurs for some users and not others with the same role and permissions, when performing the exact same actions (Create Invoice). I checked their User Preferences, and they're the same between users for whom the error occurs and those for whom it doesn't. The Role for both groups is the same. The global permissions are the same. The Customer for which the Invoice is being created is the same. The fields and Item lines are filled out with the same values. The only difference I've been able to find is which User is doing it, and the Subsidiary the user is in. But the role they're using has access to all other subsidiaries. I think the most interesting part of this is that the script seems to be running to completion and saving a PDF of the Invoice to the filecabinet, despite the error occurring at the render.transaction function call in the afterSubmit handler, when the File.save call is encapsulated in the same try/catch block as the render.transaction call, and it occurs after the render.transaction call that triggers the error. This seems to indicate that the afterSubmit is running twice somehow, once successfully, and once after that with an error, before the Invoice that is being saved loads in the browser again. But I'm not sure how that could happen since User Event scripts can't trigger user events themselves. And still it doesn't make sense yet that it would happen for some users with the same role and permissions and not for others. The folder being saved to has permissions determined by a saved search but the criteria for the search include the role that both the erroring and non-erroring users are using to create the Invoices. And that doesn't matter anyway because the error occurs on the part of the script BEFORE the file cabinet is even accessed. I also checked whether beforeLoad or beforeSubmit functions were trying to use the same functions and they aren't using anything on that script. Only afterSubmit. Anybody have an idea on how to track this down?
a
I'd look at other UE trigger sources on the invoice than just this script. other scripts and WF looking at before and after submits. I'd also be skeptical of the line reference giving you the error pointing to the render action since you say it IS saving the pdf successfully. it might be triggering twice somehow and only one is erroring, but it might also be something else entirely and that code line ref is pointing you in the wrong direction. practically speaking... add a ton of logs to script and see what/where things are going wrong 🙂
m
Have the users clear their browser cookies/cache for netsuite. I had an issue in the past where CS wouldn't trigger until cleared
b
check for map/reduce scripts or scheduled scripts running on invoices, especially those that can be tasked from a user event script. Othewise, check that the template used for printing doesnt have some subsidiary specific behavior in its expressions