The scripts below show how users can use SuiteScript to get the price level values of an item record.
//Function showing how to retrieve values via nlapiSearchRecord
function getPriceLevels()
{
var filters = new Array();
filters[0] = new nlobjSearchFilter( 'internalid', null, 'is', 8); //Hard coding item internalID 8
var columns = new Array();
columns[0] = new nlobjSearchColumn( 'itemid');
columns[1] = new nlobjSearchColumn( 'baseprice');
columns[2] = new nlobjSearchColumn( 'otherprices') //otherprices will pull all price levels in the results
var searchresults = nlapiSearchRecord( 'item', null, filters, columns );
//Price levels start with 'baseprice', then 'price' + 2 and up.
var itemName = searchresults[0].getValue('itemid');
var baseprice = searchresults[0].getValue('baseprice');
var price2 = searchresults[0].getValue('price2');
var price3 = searchresults[0].getValue('price3');
var price4 = searchresults[0].getValue('price4');
var price5 = searchresults[0].getValue('price5');
//When used client side.
alert(itemName + ": "+ baseprice +", "+ price2 +", "+ price3 +", "+ price4 +", "+ price5);
//When used server side
nlapiLogExecution('DEBUG', 'prices:', itemName +": " + baseprice +", "+ price2 +", "+ price3 +", "+ price4 +", "+ price5);
}
//Function showing how to pull the values client side directly from the open form.
function getPriceLevels2()
{
var price2 = nlapiGetFieldValue(price2);
alert(price2);
}
No comments:
Post a Comment