Let me say I am desperate for some help in getting this to work as I have been working on this for a week with no success.
My setup is as follows:
In the Sales Order User Event script, I am adding a sublist button to show the customer's Purchase History by calling a function in the Sales Order client script. I reference a function in the client script rather than directly opening the Suitelet from the button in order to get the Entity value to pass into the Suitelet to filter the results (if there is another way to do this, please let me know):
objSublist.addButton({
id: 'custpage_custpurchhist',
label: 'Purchase History',
functionName : 'purchHist()'
});
In the Sales Order client script, I have a function purchHist(), which simply gets the Entity and appends it as a parameter to the URL used to call the Suitelet:
var custId = rec.getValue({fieldId: 'entity'});
//log.debug({title: 'custId', details: custId});
var custParam = '&custparam_custId=' + encodeURI(custId);
//log.debug({title: 'custIdParam', details: custParam});
window.open('/app/site/hosting/scriptlet.nl?script=637&deploy=2' + custParam, 'Purchase History', params);
The pop-up window opens, executing the Suitelet in which I create the form, add the sublist, and return the customer's item purchase history along with a checkbox column to allow the user to check the desired item(s). This all works fine. Where I am stuck is how do I return these value(s) to the parent window (the Sales Order)? The SuiteScript 2.0 solution posted in SuiteAnswers Answer ID 86121 does not work. When I try this approach, the context.write statement just writes the string into the pop-up window that was displaying the purchase history like this:
I also question why the SuiteScript 2.0 solution is building the string for the context.write using a SuiteScript 1.0 method, that doesn't seem right either.
All I really need to do is pass either an object, or a delimited string containing the item(s) back to the Sales Order client script where I can then call the appropriate currentRecord.sublist methods to set the sublist value and add new lines for each item returned, but I just cannot see how to pass the item list back.