I have written several scripts in the past, but this is my first attempt at writing a Suitelet and need some help. What I am trying to do is add a Sublist button on the Sales Order that, when clicked, opens a Suitelet that displays a custom List with the results of a search based on the SO's customer and the currently selected item in the Item Sublist. Essentially, a pop-up window.
The documentation example "Sample Custom List Page" script (https://suiteanswers.custhelp.com/app/answers/detail/a_id/74606) is conceptually just what I am trying to do (we'll run with their example to keep it relevant) with the only change being to populate the rows based on the search results of the customer's purchase history for the item. I understand how to create the button in the beforeLoad event of the User Event script and define the Suitelet function. I understand how to use the List.clientScriptFileId in the Suitelet to define the Client script function, but how do I get the customer and the item from the currently selected line on the SO into the Client script function to perform the search (keeping in mind this may be a newly create, unsaved, SO)? Wouldn't this Client script pertain to the Suitelet and not the initiating Sales Order, so calling CurrentRecord.getSublistValue from the Suitelet's Client script function would be undefined because the Item sublist does not exist in the Suitelet?
If that is true, I thought about how would I pass the values into the Suitelet, but get stumped there too since the Suitelet function is defined in the beforeLoad of the User Event and the customer and item are unknown at that point.