I've got a puzzling challenge for an item fulfillm...
# suitescript
r
I've got a puzzling challenge for an item fulfillment script. I use an external system to extract serial numbers (issueinventorynumber) and then need to put them into the inventoryDetail of serialized items. My approach to get around the client issue of adding iventoryDetail was to work on the linked Sales Order. This was fine until multi-line was introduced. My question, how can I refer to the line in the item fulfillment to the one in the Sales Order to add the inventoryDetail? Or, am I going about this all wrong with modifying the sales order in the first place.
b
its unusual to use client script in an integration
usually involves server to server
s
I would think adding inventory detail at item fulfillment time is perhaps more common
r
@Shawn Talbert That is ideal, but in the client script cannot work on the inventoryDetail record. Note, this is being done to validate the serial numbers actually exist in the destination. I would need to check if the "Save" action works with a quantity specified and no Serial Numbers provided. I was getting notifications that nothing can happen as the Serial Numbers do not match the quantity, which I believe was preventing the User Event script from running to fill it out.
b
client script supports getting values from inventory details
r
@battk "getting" but not "Setting" on the Item Fulfillment Create record (currentRecord)
The server is doing the retrieval, but getting the serial numbers to update the quantity to fill plus the serial numbers is what's happening. Flow: User: Fulfill sales order Scan a code Submit to our system via a client script -> suiteScript Returns serial numbers These need to then get put in on the inventory detail User reviews the quantity to check if more need to be scanned (or removed if too many) User finally submits the Item Fulfillment record
b
this actually looks like you can do this from a client script deployed to the inventory detail record
r
interesting, so from the ue setup the call into the inventory detail script?
b
use a record level client script deployed to the inventory detail
r
So in this case, opening the inventory detail would access the underlying "currentRecord" to get the item to decode?
Specifically, if I'm in an IF create. How can I reference the parent. Attempting to search for this now
OK, getting the URL will allow me to see the source transaction id via 'subrecord_transform_from_parent_id' but this still doesn't help with retrieving the parent "create" barcode field.
b
Window.parent will allow access to the parent window
which allows you to use its require function to get access to its version of N/currentRecord
r
thanks
Struggling with this as I haven't done much in the window.parent space, is there a snipping on how to do this properly? window.parent.require is not accessible in the page init.
b
what does your attempt look like
r
I was trying something with the window.opener, but that doesn't exist
Copy code
window.opener.require(['N/currentRecord'], function (sourceRecord: record.ClientCurrentRecord) {
}
b
no idea what you have going on with the parameters
r
I'm lost on the setup
b
there is no sourceRecord, record or ClientCurrentRecord
r
The window.opener doens't exist and swapping "opener" with "parent" gives me a typescript issue.
b
im not very surprised, the N/currentRecord Module only has one method, ands its name doesnt match any of your inputs
r
Do I ignore the message about window.parent.require? This is regardless if I change to the following:
Copy code
window.parent.require(['N/currentRecord'], function (currentRecord: record.ClientCurrentRecord) { }

Property 'require' does not exist on type 'Window'
b
ideally you setup your globals to include it
👀 1
r
OK added require to my globals, but I'm still missing something, this is hitting bootstrap for dependency checks then falling out.
Copy code
window.parent.require(['N/currentRecord'], function (currentRecord) {
            const parentRecord = currentRecord.get()
            const barcodesInput = parentRecord.getSublistText({
                sublistId: 'item',
                fieldId: 'barcode',
                line: 0
            });
            console.log('Inventory Detail pageInit: ' + barcodesInput);
        });
Sorry, it's working I'm just using the wrong request. Fixed it and now I'm on my way. Thank you for being patient and helping out!