I'm trying to set the inventory detail with a user...
# suitescript
c
I'm trying to set the inventory detail with a user event script, since creating subrecord isn't possible in client script according to the documentation, but I can't seem to pass the validation. What would be our way to go to set the inventory detail in a item fulfillment based on another custom field without actually setting it by hand? Would it even be possible?
z
Are you using serial numbers?
m
This answer might be helpful, I'm doing something similar for Inv Transfers and this worked perfectly. https://stackoverflow.com/questions/43526532/unable-to-set-inventory-detail-on-item-fulfillment-record-suitescript-2#answer-43531926
c
Using lot numbers in our case.
m
If you know what lot you're going to use, I would go about it similar to this. I have a search that pulls that ID of that inventory number and set it to that sublist.
Copy code
//Set Detail Box
var inventoryDetailRecord = to.getSublistSubrecord({
    sublistId: 'inventory',
    fieldId: 'inventorydetail',
    line: i
});

inventoryDetailRecord.setSublistValue({
    sublistId: 'inventoryassignment',
    fieldId: 'issueinventorynumber',
    value: result.getValue({
        name: "internalid",
        join: "inventoryNumber"
    }),
    line: i
});

inventoryDetailRecord.setSublistValue({
    sublistId: 'inventoryassignment',
    fieldId: 'quantity',
    value: qty,
    line: i
});
//End Detail Box
c
The thing is, we have created a custom popup suitelet to select our lot numbers, let's name it a customized inventory detail popup. After selecting the lot numbers you want to use, I want to create / adjust the inventory detail of that line. I thought of using the beforeSubmit but that's triggered after the line validation (aka a message telling that inv detail is mandatory) and a client script can't create subrecords so I'm kinda stuck
b
Depends on how much dom manipulation you want to do
With the maximum being you manipulate the item machine to look how you want it to be
c
So I was right that with the standards within NetSuite we can't achieve this? So it's either thinking of a workaround using a quantity 1 and random lot which we override with our beforeSubmit function, or manipulating the DOM. Choosing between the 2 evils I guess
b
And the minimum being you programmatically click the inventory detail button to trigger a client script on an inventory detail to do your work and then programmatically click the ok button
Understand When Subrecords Are Read-Only documents when subrecords are read only
though its slightly untrue, you can get away with creating subrecords in client script if they only use body fields, which essentially means only addresses
c
Yeh I read that documentation and that's what I was afraid of. Thanks will think of what to do
j
Hi @Christiaan I'm planning to do the same thing, can you share how you do the customized inventory detail popup? I have my custom sublist field, but I'm not sure how to call the link of suitelet page from each line. Thanks in advanced! 🙂
c
Hi @Jars, I've created a script to load up the Suitelet where we have a customized lot number selection form. In this form we choose the various lots we want to use and click on the button to confirm our selection. In the client script of the Suitelet I call functions within the window.opener to set a custom field on the line level and eventually used DOM manipulation to automate the filling of the original inventory detail based on the custom field we filled with the window.opener earlier on. The way to trigger the suitelet popup is by using a checkbox field on the transaction line level. When clicking this the fieldChanged event will be triggered and we can reset the checkbox value and open the suitelet with the corresponding parameters like item id, location id and more.
103 Views