So I'm trying to create a custom Reallocate Items Page with the main difference is the data in the Expected Ship Date. What I want to do is, to populate the sub-list based on what is in the Item ID and Location. Just like how the Standard Reallocate Items work.
So far I have created a the ff js as a Suit let for the page.
var form = nlapiCreateForm('Reallocate Items');
nlapiLogExecution('DEBUG', 'DEBUG', form);
form.setScript('customscriptcust_reallocate_field_change');
var item = form.addField('item','select', 'Item','item');
var location = form.addField('location','select', 'Location','location');
var qtyonhand = form.addField('qtyonhand','float', 'Quantity On Hand');
qtyonhand.setDisplayType('disabled');
var qtycommitted = form.addField('qtycommitted','text', 'Quantity Committed');
qtycommitted.setDisplayType('disabled');
var qtyrequired = form.addField('qtyrequired','text', 'Quantity Required');
qtyrequired.setDisplayType('disabled');
var qtypicked = form.addField('qtypicked','currency', 'Quantity Picked');
qtypicked.setDisplayType('disabled');
var units = form.addField('unitofmeasure','select', 'Units','unitstype');
units.setDisplayType('disabled');
var sublist = form.addSubList('sublist','list', '')
var checkbox = sublist.addField('checkbox', 'checkbox', 'Allocate');
var orddate = sublist.addField('orderdate', 'date', 'Order Date');
orddate.setDisplayType('disabled');
var expshipdate = sublist.addField('cust_tl_expectedshipdate', 'date', 'Custom Expected Ship Date');
expshipdate.setDisplayType('disabled');
var custreqdate = sublist.addField('custreqdate', 'date', 'Customer Request Date');
custreqdate.setDisplayType('disabled');
var ordernumber = sublist.addField('ordernumber', 'text', 'Order No.');
ordernumber.setDisplayType('disabled');
var specialorder = sublist.addField('specialorder', 'text', 'Special Order');
specialorder.setDisplayType('disabled');
var customer = sublist.addField('customer', 'select', 'Customer','customer');
customer.setDisplayType('disabled');
var qtyord = sublist.addField('qtyord', 'float', 'Quantity Ordered');
qtyord.setDisplayType('disabled');
var qtyremaining = sublist.addField('qtyremaining', 'float', 'Quantity Remaining');
qtyremaining.setDisplayType('disabled');
var commit = sublist.addField('commit', 'text', 'Commit');
commit.setDisplayType('disabled');
var qrtcommitted = sublist.addField('qtycommitted', 'float', 'Quantity Committed');
form.addSubmitButton('Submit');
form.addResetButton('Reset');
response.writePage( form );
And here is my Client Script.
if ((name === 'item' || name === 'location') && !isEmpty(nlapiGetFieldValue("item")) && !isEmpty(nlapiGetFieldValue("location"))){
var item = nlapiGetFieldValue('item');
var unitstype = nlapiLookupField('item',item,'unitstype');
nlapiSetFieldValue('unitofmeasure',unitstype);
var location = nlapiGetFieldValue('location');
var filters = new Array();
filters[0] = new nlobjSearchFilter( 'inventorylocation', null, 'anyof', location );
filters[1] = new nlobjSearchFilter('internalid', null, 'anyof', item);
var columns = new Array();
columns[0] = new nlobjSearchColumn('locationquantitycommitted');
columns[1] = new nlobjSearchColumn('locationquantityonhand');
var search = nlapiSearchRecord( 'item', null, filters, columns );
if (search){
var searchrow = search[0];
var quantitycommitted = searchrow.getValue( 'locationquantitycommitted' );
var quantityonhand = searchrow.getValue( 'locationquantityonhand' );
//var quantitypicked = searchrow.getValue( 'quantitypicked' );
nlapiSetFieldValue('qtycommitted',quantitycommitted);
nlapiSetFieldValue('qtyonhand',quantityonhand);
nlapiSetFieldValue('qtypicked', '100');
}
}
}
My question is how do I populate the sub-list just like how it works in the Reallocate Items? Thanks!