As a newcomer to NetSuite scripting, I am working on populating 3 custom body fields within an Item Fulfillment form. The fields I need to populate are Line Item Name, Line Item Class, and Line Item Count (which represents the total count of line items in the fulfillment form).
To achieve this, I am utilizing
nlapiGetCurrentLineItemText('item', 'class');
to retrieve the item's Class, nlapiGetCurrentLineItemText('item', 'item');
to fetch the item's name, and nlapiGetLineItemCount('item');
to obtain the line item count. I then use nlapiSetFieldValue
to fill in the necessary fields.
I have configured this script to execute during the Page Init event (although I am uncertain if this is the correct event). However, I am encountering two issues:
- The Class and Item Count fields successfully populate when processing the Fulfill Sales Order page. Yet, the Item name field remains unpopulated. Any insights into why this may be happening?
- During bulk order fulfillment (processing multiple orders simultaneously on the Fulfill Orders page), none of the fields are being populated. It appears as though the script only triggers when manually fulfilling orders, rather than automatically in bulk. How can this issue be addressed?
The latter issue holds greater significance, especially when automating order fulfillments with the need for accurate field population while handling between 100-200 orders per day.
I hope my explanation has been clear. Thank you for your assistance!
Below is the current script:
function pageInit() {
{
var category = nlapiGetCurrentLineItemText('item', 'class');
var sku = nlapiGetCurrentLineItemText('item', 'item');
var count = nlapiGetLineItemCount('item');
nlapiSetFieldValue('custbody_itemcategory', category);
nlapiSetFieldValue('custbody_itemsku', sku);
nlapiSetFieldValue('custbody_skucount', count);
}
}