Suitlet script sample code for item selection:
Here two sublists are used in the suitlet. The first sublist will list the item this sublist lines have a button Named “Add item”. The second sublist is an editable sublist where we can add new lines. On the “Add item ” button click on the first sublist line, and the specified sublist line item details will be added to the second sublist.
/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
/*************************************************************************************************************************
* SecondSourceRx
* SSRX-575 Sales order item selection page update
* Epic: SSRX-573
*
*********************************************************************************************************************
*
* Author: Jobin & Jismi
*
* Date Created : 12-February-2024
*
* Description : This is the item selection page to add item in the sales order.
*
* REVISION HISTORY
*
* @version 1.0 SSRX-575 : 12-February-2024 : Created the initial build by JJ0053
*
**************************************************************************************************************************/
define(['N/record', 'N/search', 'N/runtime', 'N/ui/serverWidget'],
/**
* @param{record} record
* @param{search} search
*/
(record, search, runtime, serverWidget) => {
let scr = `jQuery(document).ready(function () {
// console.info('document.ready');
let recObj=currentRecord.get();
// focus on input field selects all in field
jQuery('[name^="custpage_last_sell_price"], [name^="custpage_quantity"]').on('focus', function (event) {
event.preventDefault();
/* Act on the event */
jQuery(this).select();
});
// update button on lines already in the cart
let cartCount = recObj.getLineCount('custpage_cart');
let items = [];
for (let int = 0, count = cartCount; int < count; int++) {
items.push(recObj.getSublistValue({sublistId:'custpage_cart', fieldId:'custpage_item', line:int}));
}
// console.info('cart contents', items);
for (let ant = 0, cant = items.length - 1; ant <= cant; ant++) {
jQuery('button#add-' + items[ant]).css({
'backgroundColor': '#419641',
'color': 'whitesmoke',
'cursor': 'not-allowed',
'display': 'inline-block',
'padding': '6px 12px',
'margin-bottom': '2px',
'font-size': '14px',
'font-weight': '400',
'line-height': '1.42857143',
'text-align': 'center',
'white-space': 'nowrap',
'vertical-align': 'middle',
'border': '1px solid #398439',
'border-radius': '2px'
}).html('Added!');
}
jQuery('button[id^="add-"]').click(function (e) {
// console.info('AddToCart - btn', e);
e.preventDefault();
let item = jQuery(this).attr('id').replace('add-', '');
let lineNumber = jQuery(this).attr('data-line');
let itemName = recObj.getSublistValue({sublistId:'custpage_results', fieldId:'custpage_item_name', line:Number(lineNumber)-1});
let quantity = recObj.getSublistValue({sublistId:'custpage_results', fieldId:'custpage_quantity', line:Number(lineNumber)-1});
let sellprice = recObj.getSublistValue({sublistId:'custpage_results', fieldId:'custpage_last_sell_price', line:Number(lineNumber)-1});
console.log('itemName',itemName)
// let quantity = jQuery('input#'+item).val();
// let sellprice = jQuery('input#sellprice-'+item).val();
// give alert and stop if quantity or sellprice are not populate
if (!sellprice || sellprice == '' || !quantity || quantity == '' || quantity == 0) {
alert("Sell Price and Quantity are required fields.");
return false;
}
let lotNumber = jQuery('#lotexpiration-' + item).val();
let description = nlapiGetLineItemValue('custpage_results', 'custpage_description', lineNumber);
if (lotNumber) {
let lotNumberArray = lotNumber.split('-');
}
// Add Item to "Cart"
recObj.selectNewLine('custpage_cart');
recObj.setCurrentSublistValue({sublistId:'custpage_cart', fieldId:'custpage_item', value:item|| ''});
recObj.setCurrentSublistValue({sublistId:'custpage_cart', fieldId:'custpage_item_name', value:itemName|| ''});
recObj.setCurrentSublistValue({sublistId:'custpage_cart', fieldId:'custpage_quantity', value:quantity|| ''});
recObj.setCurrentSublistValue({sublistId:'custpage_cart', fieldId:'custpage_sellprice', value:sellprice|| ''});
recObj.setCurrentSublistValue({sublistId:'custpage_cart', fieldId:'custpage_description', value:description|| ''});
if (lotNumber) {
recObj.setCurrentSublistValue({sublistId:'custpage_cart', fieldId:'custpage_lot_expiration', value:lotNumberArray[1] + '-' + lotNumberArray[2]|| ''});
recObj.setCurrentSublistValue({sublistId:'custpage_cart', fieldId:'custpage_lot_expiration_hidden', value:lotNumberArray[0]|| ''});
}
recObj.commitLine('custpage_cart');
// Remove Quantity and update Button to reflect the
// Item existing in the Cart
nlapiSetLineItemValue('custpage_results', 'custpage_quantity', lineNumber, '');
jQuery('button#add-' + item).html('Added!');
let bgColor = jQuery('button#add-' + item).css('backgroundColor');
let textColor = jQuery('button#add-' + item).css('color');
jQuery('button#add-' + item).css({
'backgroundColor': '#419641',
'color': 'whitesmoke',
'cursor': 'not-allowed',
'display': 'inline-block',
'padding': '6px 12px',
'margin-bottom': '2px',
'font-size': '14px',
'font-weight': '400',
'line-height': '1.42857143',
'text-align': 'center',
'white-space': 'nowrap',
'vertical-align': 'middle',
'border': '1px solid #398439',
'border-radius': '2px'
});
});
});`;
/**
* function to create the html for the item add button
* @param {String} type
* @param {String} item
* @param {String} lineNumber
* @returns {String}
*/
function getHtml(type, item, lineNumber) {
let html = '';
if (type == 'quantity') {
html += '<input id="' + item + '" type="integer" />';
}
else if (type == 'add') {
html += '<button id="add-' + item + '" type="button" data-line="' + lineNumber + '" style="cursor:pointer;background-color : #337ab7;color : whitesmoke;display: inline-block;padding: 6px 12px;margin-bottom: 2px;font-size: 14px;font-weight: 400;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;border: 1px solid #245580;border-radius: 2px;">Add to Cart</button>';
}
return html;
}
/**
* function to create html
* @param {String} item
* @param {String} lotexpiration
* @returns {String}
*/
function getHtmlForLotExpiration(item, lotexpiration) {
let html = '';
html += '<select id="lotexpiration-' + item + '">';
for (let i = 0; i < lotexpiration.length; i++) {
html += '<option value="' + lotexpiration[i].id + '-' + lotexpiration[i].inventorynumber + '-' + lotexpiration[i].expirationdate + '">';
html += lotexpiration[i].inventorynumber + '-' + lotexpiration[i].expirationdate;
html += '</option>';
}
html += '</select>';
return html;
}
/**
*
* @param {String} item
* @param {String} sellprice
* @returns {String}
*/
function getHtmlForSellPrice(item, sellprice) {
let html = '';
html += '<input id="sellprice-' + item + '" value="' + sellprice + '"/>';
return html;
}
/**
*
* @param {String} name
* @param {String} item
* @param {String} value
* @returns {String}
*/
function getHtmlForItem(name, item, value) {
let html = '<input id="' + name + '-' + item + '" value = "' + value + '" readonly/>';
return html;
}
/**
* Function to serch items
* @param {String} nameFilter
* @param {String} brandFilter
* @param {String} descFilter
* @param {String} drugFamilyFilter
* @param {String} customerId
* @param {String} itemFilter
* @param {String} marketingCategoryFilter
* @param {String} dateAddedFilter
* @param {String} agFilter
* @param {String} shortDateFilter
* @param {String} specialsFilter
* @param {String} pageFilter
* @returns {object}
*/
function getItemsVersion2(nameFilter, brandFilter, descFilter, drugFamilyFilter, customerId, itemFilter, marketingCategoryFilter, dateAddedFilter, agFilter, shortDateFilter, specialsFilter, pageFilter) {
try {
let data = {};
data.ids = [];
data.records = {};
if (!customerId) {
return data;
}
let user = runtime.getCurrentUser();
let filter = [
["inventorylocation", "anyof", "3"],
"AND",
["isinactive", "is", "F"],
"AND",
["locationquantityavailable", "greaterthan", "0"]
];
filter.push('AND', ['pricing.customer', 'anyof', customerId]);
if (nameFilter) {
filter.push('AND')
filter.push(['itemid', 'startswith', nameFilter]);
}
if (brandFilter) {
filter.push('AND')
filter.push(['custitem_brandname', 'startswith', brandFilter]);
}
if (descFilter) {
filter.push('AND')
filter.push(['description', 'startswith', descFilter]);
}
if (drugFamilyFilter) {
filter.push('AND')
filter.push(['custitem11', 'anyof', drugFamilyFilter]);
}
if (itemFilter) {
filter.push('AND')
filter.push(['custitem_2srx_item_number', 'startswith', itemFilter]);
}
if (marketingCategoryFilter) {
filter.push('AND')
filter.push(['custitem21', 'anyof', marketingCategoryFilter]);
}
if (dateAddedFilter) {
filter.push('AND')
filter.push(['custitem24', 'onorafter', dateAddedFilter]);
}
if (agFilter && agFilter == 'T') {
filter.push('AND')
filter.push(['custitem19', 'is', 'T']);
}
if (shortDateFilter && shortDateFilter == 'T') {
filter.push('AND')
filter.push(['custitem22', 'is', 'T']);
}
if (specialsFilter && specialsFilter == 'T') {
filter.push('AND')
filter.push(['custitem_specials', 'is', 'T']);
}
log.debug('filter', filter);
let itemSearchObj = search.create({
type: 'item',
filters: filter,
columns: [
search.createColumn({ name: 'internalid' }),
search.createColumn({ name: 'itemid' }),
search.createColumn({ name: 'custitem_2srx_item_number' }),
search.createColumn({ name: 'custitem10' }),
search.createColumn({ name: 'custitem12' }),
search.createColumn({ name: 'price10' }),
search.createColumn({ name: 'maximumquantity' }),
search.createColumn({ name: 'custitem_brandname' }),
search.createColumn({ name: 'custitem6' }),
search.createColumn({ name: 'locationquantityavailable' }),
search.createColumn({ name: 'salesdescription', sort: search.Sort.ASC }),
search.createColumn({ name: 'baseprice' }),
search.createColumn({ name: 'unitprice', join: 'pricing' }),
]
});
let searchResultCount = itemSearchObj.runPaged().count;
log.debug("inventorynumberSearchObj result count", searchResultCount);
let pagedData = itemSearchObj.runPaged({
pageSize: 500
});
let pageCount = pagedData.pageRanges.length;
log.debug('pageCount', pageCount);
let hasPage = pagedData.pageRanges.filter((pageRange) => {
return Number(pageRange.index) == (pageFilter ? Number(pageFilter) - 1 : 0);
});
log.debug('hasPage', hasPage);
pageFilter = hasPage.length ? Number(hasPage[0].index) + 1 : 1
// pagedData.pageRanges.forEach((pageRange) => {
// log.debug('index', pageRange.index)
if (pageCount) {
let page = pagedData.fetch({ index: hasPage.length ? hasPage[0].index : 0 });
page.data.forEach((result) => {
let id = result.getValue('internalid');
// log.debug('id', id);
if (user.id != 25049) {
data.ids.push(id);
data[id] = {
'custpage_item': id,
'custpage_item_name': result.getValue('itemid'),
'custpage_item_number': result.getValue('custitem_2srx_item_number'),
'custpage_drug_color': result.getText('custitem10'),
'custpage_case_pack': result.getText('custitem12'),
'custpage_floor_price': result.getValue('price10'),
'custpage_max_qty': result.getValue('maximumquantity'),
'custpage_brand': result.getValue('custitem_brandname'),
'custpage_manufacturer': result.getText('custitem6'),
'custpage_available': (isNaN(parseInt(result.getValue('locationquantityavailable'))) ? '0' : removeDecimal(result.getValue('locationquantityavailable'))),
'custpage_description': result.getValue({ name: 'salesdescription', sort: search.Sort.ASC }),
'custpage_baseprice': '$' + result.getValue('baseprice'),
'custpage_last_sell_price': '$' + result.getValue({ name: 'unitprice', join: 'pricing' }),
'custpage_quantity': '0',
'custpage_add': getHtml('add', id, data.ids.length)
};
} else {
if (data.ids.length <= 50) {
data.ids.push(id);
data[id] = {
'custpage_item': id,
'custpage_item_name': result.getValue('itemid'),
'custpage_item_number': result.getValue('custitem_2srx_item_number'),
'custpage_drug_color': result.getText('custitem10'),
'custpage_case_pack': result.getText('custitem12'),
'custpage_floor_price': result.getValue('price10'),
'custpage_max_qty': result.getValue('maximumquantity'),
'custpage_brand': result.getValue('custitem_brandname'),
'custpage_manufacturer': result.getText('custitem6'),
'custpage_available': (isNaN(parseInt(result.getValue('locationquantityavailable'))) ? '0' : removeDecimal(result.getValue('locationquantityavailable'))),
'custpage_description': result.getValue({ name: 'salesdescription', sort: search.Sort.ASC }),
'custpage_baseprice': '$' + result.getValue('baseprice'),
'custpage_last_sell_price': '$' + result.getValue({ name: 'unitprice', join: 'pricing' }),
'custpage_quantity': '0',
'custpage_add': 'F'
};
}
}
return true;
});
}
return { data: data, pageCount: pageCount, pageFilter: pageFilter };
} catch (e) {
log.error('error@getItemsVersion2', e);
return { data: {}, pageCount: 0, pageFilter: 1 };
}
}
/**
* function to remove decimal
* @param {String} value
* @returns {String}
*/
function removeDecimal(value) {
return value.replace('.0', '');
}
/**
* Function to get lot data
* @param {String} data
* @returns {Object}
*/
function getLotExpiration(data) {
try {
let filter = [["quantityavailable", "greaterthan", "0"]];
let inventorySearchObj = search.create({
type: 'inventorynumber',
filters: filter,
columns: [
search.createColumn({ name: 'inventorynumber', summary: 'GROUP' }),
search.createColumn({ name: 'expirationdate', summary: 'GROUP' }),
search.createColumn({ name: 'internalid', summary: 'GROUP' }),
search.createColumn({ name: 'internalid', join: 'item', summary: 'GROUP' })
]
})
// log('Results found for getLotExpiration : ', results.length);
let lotExpirations = {};
lotExpirations.ids = [];
let pagedData = inventorySearchObj.runPaged({
pageSize: 1000
});
pagedData.pageRanges.forEach((pageRange) => {
let page = pagedData.fetch({ index: pageRange.index });
page.data.forEach((result) => {
let lotExpirationObject = {};
lotExpirationObject.id = result.getValue({ name: 'internalid', summary: 'GROUP' });
itemid = result.getValue({ name: 'internalid', join: 'item', summary: 'GROUP' });
lotExpirationObject.itemid = itemid;
lotExpirationObject.inventorynumber = result.getValue({ name: 'inventorynumber', summary: 'GROUP' });
lotExpirationObject.expirationdate = result.getValue({ name: 'expirationdate', summary: 'GROUP' });
if (lotExpirations.ids.indexOf(itemid) == -1) {
lotExpirations.ids.push(itemid);
lotExpirations[itemid] = [];
}
lotExpirations[itemid].push(lotExpirationObject);
return true;
});
});
for (let i = 0; i < lotExpirations.ids.length; i++) {
let id = lotExpirations.ids[i];
if (data[id]) {
// log('Found LotExpiration for id: ', lotExpirations[id]);
data[id].custpage_lot_expiration = getHtmlForLotExpiration(id, lotExpirations[id]);
}
}
return data;
} catch (e) {
log.error('error@getLotExpiration', e);
return data;
}
}
/**
* Function to set sublist
* @param {Object} sublist
* @param {Array} sublistRecords
*/
function setResultSublist(sublist, sublistRecords) {
try {
for (let i = 0; i < sublistRecords.length; i++) {
for (let key in sublistRecords[i]) {
if (sublistRecords[i][key])
sublist.setSublistValue({
id: key,
value: sublistRecords[i][key],
line: i
});
}
}
} catch (e) {
log.error('error@setResultSublist', e);
}
}
/**
* Defines the Suitelet script trigger point.
* @param {Object} scriptContext
* @param {ServerRequest} scriptContext.request - Incoming request
* @param {ServerResponse} scriptContext.response - Suitelet response
* @since 2015.2
*/
const onRequest = (scriptContext) => {
try {
let params = scriptContext.request.parameters;
log.debug('params', params);
p_data = {};
for (let param in params) {
if (param !== 'script' && param !== 'deploy' && param !== 'callback' && param !== 'compid' && param != '_' && param != 'h') p_data[param] = params[param];
}
let form, sublist;
let nameFilter = '';
let brandFilter = '';
let descFilter = '';
let drugFamilyFilter = '';
let itemFilter = '';
let marketingCategoryFilter = '';
let dateAddedFilter = '';
let agFilter = '';
let shortDateFilter = '';
let specialsFilter = '';
let pageFilter = 1;
if (scriptContext.request.method == 'GET' || scriptContext.request.method == 'POST') {
let startOfExecution = new Date().getTime();
let cart_contents = [];
if (scriptContext.request.method == 'POST') {
/* Extract Cart data */
let sublist_fields = p_data.custpage_cartfields.split('u0001');
let sublist_data = p_data.custpage_cartdata.split('u0002');
for (let i = 0, count = sublist_data.length; i < count; i++) {
let line_data = sublist_data[i].split('u0001');
let temp = {}, valid = false;
for (let f = 0, count_f = line_data.length; f < count_f; f++) {
temp[sublist_fields[f]] = line_data[f];
if (line_data[f]) valid = true;
}
if (valid) cart_contents.push(temp);
}
nameFilter = params['custpage_namefilter'];
brandFilter = params['custpage_brandfilter'];
descFilter = params['custpage_descfilter'];
drugFamilyFilter = params['custpage_drugfamilyfilter'];
itemFilter = params['custpage_itemfilter'];
marketingCategoryFilter = params['custpage_category'];
dateAddedFilter = params['custpage_date'];
agFilter = params['custpage_ag'];
shortDateFilter = params['custpage_short_date'];
specialsFilter = params['custpage_specials'];
pageFilter = params['custpage_page'];
}
/* Create Form */
let user = runtime.getCurrentUser();
form = serverWidget.createForm({ title: 'Search & Add Items', hideNavBar: false });
let itemField = form.addField({ id: 'custpage_itemfilter', type: 'text', label: 'Item #' });
itemField.defaultValue = itemFilter;
let ndcField = form.addField({ id: 'custpage_namefilter', type: 'text', label: 'NDC' });
ndcField.defaultValue = nameFilter;
let descField = form.addField({ id: 'custpage_descfilter', type: 'text', label: 'Generic Description' });
descField.defaultValue = descFilter;
let drugFamilyField = form.addField({ id: 'custpage_drugfamilyfilter', type: 'select', label: 'Drug Family', source: 'customlist203' });
drugFamilyField.defaultValue = drugFamilyFilter;
let brandField = form.addField({ id: 'custpage_brandfilter', type: 'text', label: 'Brand Name' })
brandField.defaultValue = brandFilter;
brandField.updateBreakType({ breakType: "startcol" });
let marketCatField = form.addField({ id: 'custpage_category', type: 'select', label: 'Marketing Category', source: 'customlist237' });
marketCatField.defaultValue = marketingCategoryFilter;
let dateAddField = form.addField({ id: 'custpage_date', type: 'date', label: 'Items Added Since' });
dateAddField.defaultValue = dateAddedFilter;
let agField = form.addField({ id: 'custpage_ag', type: 'checkbox', label: 'AG' })
agField.defaultValue = agFilter;
agField.updateBreakType({ breakType: "startcol" });
let shortDateField = form.addField({ id: 'custpage_short_date', type: 'checkbox', label: 'Short Date' });
shortDateField.defaultValue = shortDateFilter;
let specialField = form.addField({ id: 'custpage_specials', type: 'checkbox', label: 'Specials' });
specialField.defaultValue = specialsFilter;
let customerId = scriptContext.request.parameters['custpage_customer'] || null;
log.debug('customerId', customerId);
let customer = form.addField({ id: 'custpage_customer', type: 'text', label: 'Customer' });
customer.updateDisplayType({ displayType: 'hidden' });
customer.defaultValue = params['custpage_customer'];
let pageField = form.addField({ id: 'custpage_page', type: 'select', label: 'Page' });
let htmlField = form.addField({ id: 'custpage_html', type: 'inlinehtml', label: 'Html' });
htmlField.defaultValue = "<script>jQuery(function($){require(['N/currentRecord'], function(currentRecord){" + scr + ";})})</script>"
form.clientScriptModulePath = '../SSRX-573/jj_cs_item_selection_ssrx_573.js';
// see if user can see item cost
log.debug('pageFilter', pageFilter);
let allItemsArr = getItemsVersion2(nameFilter, brandFilter, descFilter, drugFamilyFilter, customerId, itemFilter, marketingCategoryFilter, dateAddedFilter, agFilter, shortDateFilter, specialsFilter, pageFilter);
for (let i = 1; i <= allItemsArr.pageCount; i++) {
pageField.addSelectOption({
value: i,
text: 'Page-' + i
});
}
if (!allItemsArr.pageCount) {
pageField.addSelectOption({
value: 1,
text: 'Page-' + 1
});
}
log.debug('allItemsArr.pageFilter', allItemsArr.pageFilter);
pageField.defaultValue = allItemsArr.pageFilter ? allItemsArr.pageFilter : 1;
allItems = getLotExpiration(allItemsArr.data);
sublist = form.addSublist({ id: 'custpage_results', type: 'list', label: 'Search Results' });
sublist.addField({ id: 'custpage_item_number', type: 'text', label: 'Item #' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_item', type: 'select', label: 'NDC', source: 'item' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_item_name', type: 'text', label: 'Name' })
.updateDisplayType({ displayType: 'hidden' });
sublist.addField({ id: 'custpage_description', type: 'textarea', label: 'Description' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_drug_color', type: 'text', label: 'Drug Color' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_case_pack', type: 'text', label: 'Case Pack' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_manufacturer', type: 'text', label: 'Manufacturer' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_brand', type: 'text', label: 'Brand Name' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_lot_expiration', type: 'textarea', label: 'Lot Expiration' })
.updateDisplayType({ displayType: 'hidden' });
sublist.addField({ id: 'custpage_floor_price', type: 'text', label: 'Floor Price' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_baseprice', type: 'text', label: 'Base Price' })
.updateDisplayType({ displayType: 'hidden' });
sublist.addField({ id: 'custpage_available', type: 'integer', label: 'Available' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_max_qty', type: 'text', label: 'Max Qty' })
.updateDisplayType({ displayType: 'inline' });
sublist.addField({ id: 'custpage_last_sell_price', type: 'text', label: 'Sell Price' })
.updateDisplayType({ displayType: 'entry' });
sublist.addField({ id: 'custpage_quantity', type: 'float', label: 'Quantity' })
.updateDisplayType({ displayType: 'entry' });
if (user.id != 25049) {
sublist.addField({ id: 'custpage_add', type: 'textarea', label: 'Add Item' })
.updateDisplayType({ displayType: 'inline' });
}
else {
sublist.addField({ id: 'custpage_add', type: 'checkbox', label: 'Add Item' });
}
let sublistRecords = [];
for (let i = 0, count = allItems.ids.length; i < count; i++) {
sublistRecords.push(allItems[allItems.ids[i]]);
}
sublistRecords.sort(function (a, b) {
let alc = a.custpage_description.toLowerCase(), blc = b.custpage_description.toLowerCase();
return alc > blc ? 1 : alc < blc ? -1 : 0;
});
for (let i = 0, count = sublistRecords.length; i < count; i++) {
if (user.id != 25049) {
sublistRecords[i].custpage_add = getHtml('add', sublistRecords[i].custpage_item, i + 1);
}
}
setResultSublist(sublist, sublistRecords)
sublist = form.addSublist({ id: 'custpage_cart', type: 'inlineeditor', label: 'Cart' });
sublist.addField({ id: 'custpage_item_name', type: 'text', label: 'Item' })
.updateDisplayType({ displayType: 'disabled' });
sublist.addField({ id: 'custpage_item', type: 'text', label: 'Item' })
.updateDisplayType({ displayType: 'hidden' });
sublist.addField({ id: 'custpage_description', type: 'textarea', label: 'Description' })
.updateDisplayType({ displayType: 'disabled' });
sublist.addField({ id: 'custpage_lot_expiration', type: 'text', label: 'Lot Expiration' })
.updateDisplayType({ displayType: 'hidden' });
sublist.addField({ id: 'custpage_sellprice', type: 'text', label: 'Sell Price' })
.updateDisplayType({ displayType: 'disabled' });
sublist.addField({ id: 'custpage_quantity', type: 'integer', label: 'Quantity' })
.updateDisplayType({ displayType: 'normal' });
sublist.addField({ id: 'custpage_lot_expiration_hidden', type: 'text', label: 'Lot Expiration' })
.updateDisplayType({ displayType: 'hidden' });
setResultSublist(sublist, cart_contents)
form.addSubmitButton('Apply Filters and Search Again');
form.addButton({ id: 'custpage_addtotransaction', label: 'Add Items in Cart to Transaction', functionName: '_add_items()' });
form.addButton({ id: 'custpage_sale_history', label: 'Sales History', functionName: '_history()' });
scriptContext.response.writePage(form);
let endOfExecution = new Date().getTime();
let executionTime = endOfExecution - startOfExecution;
log.debug('User : ' + user.id + ', Execution time: ' + (executionTime / 1000) + ' seconds');
}
} catch (e) {
log.error('error@onRequest', e);
}
}
return { onRequest }
});