Anyone had issues with `currentRecord.cancelLine()...
# suitescript
c
Anyone had issues with
currentRecord.cancelLine()
not firing on item sublists? We have it working for certain conditions in Work Orders, and in the current implementation of a feature on POs, it works on the
expense
sublist but not on
item
sublists. The flow is we check a condition at the top of the
lineInit()
function, then based on that condition, we cancel the line to prevent edits. For the item sublist on POs, the method call silently fails.
watching following 1
It turns out that after the execution of custom deployed
lineInit()
functions, Netsuite is making a call to an internal endpoint, and the results of that call include managing field visibility and enabling/disabling for the selected line. The net effect of this is that calls made to line-related methods are ignored or reversed. I noticed that when I called a method to disable a field, I would see that field flash grey for disabled, then reenable. Examining the Network tab of my browser dev tools showed this request and that its response came after the response from the deployed client script. I updated my
lineInit()
function to include a setTimeOut with a duration greater than the max round trip for Netsuite's API call, and it functioned as I intended. This isn't a robust solution, and I ended up going in a different direction utilizing N/ui/dialog since those alerts are non-blocking, which allows the Netsuite call to resolve before the execution of my function continues. This does necessitate some additional validation of field values, since a user could click into a field on that line, trigger the N/ui/dialog alert, and still edit / submit the line while the dialog is showing. Pretty irritating that Netsuite's functionality can just override the user intent from custom scripts. I believe it's related to the Purchase Contract feature, which is why it only appears on PO line items.
d
woah. thanks for sharing your investigation