Is there any way to edit a sublist on a subrecord ...
# suitescript
e
Is there any way to edit a sublist on a subrecord (Inventory Detail on the header of a Work Order Completion transaction) in a client script on create of the transaction in dynamic mode?
b
Also, since you want to perform a task
on create
, you want
user event script
instead of
client script
e
No, I didn’t mean that, sorry. I meant I am in create mode, (as opposed to editing a record) and I need to update the quantity in the inventory detail based on other input. So, it needs to happen client side. Ideas?
From the docs: “Additionally, the functionality of the two modules varies slightly. For example, the currentRecord module does not permit the editing of subrecords, although subrecords can be retrieved in view mode.”
so, wondering if there is any way around this?
b
Could you edit the subrecord after you have saved the record?
e
i don’t think i can save the record without populating data in the inv detail… that’s the issue.
b
deploy the client script to the inventory detail instead
e
hmm… can you explain? If I am on a Work Order Completion, and on edit of the quantity I want to populate the Inv Detail quantity - how would I accomplish that client side? Deploy here, and listen for what? fieldChanged would be on the WO Completion, no?
b
you can deploy a client script on the inventory detail
so that when the user presses the inventory detail button, it automatically fills in
if you wanted field changed, then you need to do dom manipulation
the least of which is selecting the inventory detail button to click
e
got it! I actually did one better, and have 2 scripts: 1. On the WO Completion, on update of the quantity, all I needed to do here is call
getSubrecord({ fieldId: 'inventorydetail' })
- what this accomplishes is twofold, but essentially it triggers the pageInit of the Inventory Detail subrecord 2. Next, I have the script deployment on the Inv Detail which now has visibility into a) the type of order on the header that is calling it, which is necessary bec I want to limit when it runs, and b) the quantity is passed to this form 3. Now, I simply set the line value accordingly Question, though: How do I clear the icon so that it is “set” instead of blue, it’s got the “green” checkmark… so long as it appears not set, I cannot save the main form. (This forces me to simply click on the inv detail form, then close it immediately, then I can save - but the idea is to avoid having to do that.)
b
my normal advice would be to do another dom manipulation and click the ok button
however, your attempt at getting the subrecord is triggering the client script to run serverside
there is no button to click
e
it’s actually not running server side; i am calling getSubrecord client side, and the pageinit triggers in the inv detail client script… either way, not sure how to approach it from the DOM but will research it, thanks!
b
are you sure, are you able to use console.log in your client script and get logs without pressing the button?
e
No! You are correct. console is undefined. But the Client Script registers log.debug statements! It’s odd…
b
its running on the server, there is no console global on the server
you also cant do any dom manipulation, for the same reason, there is no dom
the process you described worked before since manually pressing the inventory detail button triggers client script that runs on clientside on the browser
e
so… it’s odd. I resorted to DOM but am sort of forced to have the popup come up and then I can control it and close it. would rather bypass the popping up of the inv detail altogether if that were possible… thanks
also, it’s funny how you describe this as “server” side and I tend to agree with that terminology, but there is no way to deploy a UE that I see against the Inv Detail type.
b
client scripts can be triggered on the server
they dont always run in browser
the common exceptions to running on the server instead of the browser are subrecords and the regular webstore
e
bit odd to me, but i definitely do see it. in the end, the client script pageinit function did not work in the “server” side load; I still got an error when saving the WO Completion that this inv detail was not supplied. Rather, i had to initiate a popup via a virtual “button click” (DOM) and then virtually hit “OK” - but would much rather NOT have this popup occur.
b
there are various things you can do depending on how much dom manipulation you are willing to do
the more you do, the more likely netsuite breaks it on their next hotfix
e
willing to do it all! 🙂 i just couldn’t figure it out, i guess.
understood on hotfix. anyway, i’m out of supported territory already
i tried setting the inv detail to “set” - which bypassed validation on save of the form, and allowed it to “SAVE” however it failed via an error after saving that the inv detail was missing (even though I saw in my client script that i had indeed set it)
So, this only partially worked - bypasses on save validation, but then fails to save nonetheless:
changeToSetStyle(document.getElementById('inventorydetail_helper_popup'));
b
there is an event handler attached to the inventory detail button/link
take a look at the code for how that button works
e
so, in my WO Compl client script I am doing this:
Copy code
beforeInventoryDetailOpen(null, document.getElementById('inventorydetail_helper_popup'), -1);
            NLShowChildRecordPopup('wocompl', 'inventorydetail', false, '/app/accounting/transactions/inventory/numbered/inventorydetail.nl', this, -1, {width: 700, height: 700}, '', 'inventorydetail');
Then, in my INV Detail Client script:
Copy code
saveInventoryDetails();
b
it sets up the inventory detail, and then it open an iframe
you would need to setup the inventory detail yourself, probably by calling the same function
and then create your own iframe
but making it a hidden iframe instead
e
i’m trying to skip that step - oh, just hide it… hmm
not sure how to hide it. i can set height and width, but not to 0
i would advise making your own iframe