I posted this question as a reply to an older thread in the Import / Export section, but I think it's more appropriate here.
The record type these scripts run on is Inventory Transfer.
First script is User Event type and runs Before Load. It creates a text field, adds a button, and "loads" the next script which is used to process the data.
function taBeforeLoad(type, form){
if((type == 'edit' || type == 'create') && 'userinterface' == nlapiGetContext().getExecutionContext()){
var pasteField = form.addField('custpage_paste_items', 'textarea', 'Paste Items');
pasteField.setDisplaySize(80, 20);
form.setScript('customscripttransfer_order_client'); //this is the Internal ID of the script even though we are working with Inventory Transfers
form.addButton('custpage_process_paste', 'Process Paste', 'taProcessPastedItems()');
}
}
Second script is Client type. I do not specify a function on the script record as the script itself is called via form.setScript before the record loads (above).
function taProcessPastedItems(){
var pasteItems = nlapiGetFieldValue('custpage_paste_items');
alert('pasteItems = ' + pasteItems);
var rows = pasteItems.split(',');
alert(rows[0]);
alert(rows[1]);
[COLOR=#000000][FONT=arial]alert(rows[2]);
alert(rows[3]);
nlapiSelectNewLineItem('inventory');
nlapiSetCurrentLineItemValue('inventory', 'item', rows[0], true, true);
nlapiSetCurrentLineItemValue('inventory', 'adjustqtyby', rows[1], true, true);
nlapiSelectNewLineItem('inventoryassignment');
nlapiSetCurrentLineItemValue('inventoryassignment' ,'issueinventorynumber', rows[2]);
nlapiSetCurrentLineItemValue('inventoryassignment' , 'quantity', rows[3]);
nlapiCommitLineItem('inventoryassignment');
nlapiCommitLineItem('inventory');
}[/FONT][/COLOR]
The Client script at the moment is meant to just handle one set of data (item,quantity,lotno,lotqty): 8.252.0.0.03,300,12345,300
Expected result is a line item on the inventory transfer that shows: Item No. 8.252.0.0.03, 300 QTY To Transfer, and (for Inventory Detail) Lot No. 12345, Quantity 300.
I used the alerts to confirm the data (looks good there). I must be doing something wrong with setting/committing the data to the line.
Appreciate any help!