Whats the best way to retrieve an item’s price bas...
# suitescript
k
Whats the best way to retrieve an item’s price based on the Customer ID in a suitelet search? Currently, I am passing the customer ID from the item drill-down template like so
filters[1] _=_
new
_nlobjSearchFilter_('customer', 'pricing', 'is', custId)
and then trying to access the price with
_if_ (_typeof_(results[i]._getValue_('onlinecustomerprice')) _!=_ 'undefined' ) {
_var_ onlineCustomerPrice _=_ results_[_i_].getValue(_'onlinecustomerprice'_)_;
}
However, it’s just getting the regular non-logged in price. Any thoughts?
b
there are a lot of pricing related features in netsuite
which one (or god forbid ones) are you using
k
Im trying to access
pricinglevel
Based on the accessrole of a customer
Im using
salespricehtml
to get the correct price on the detail pages currently
b
There are a lot of pricing related features that can change how you access pricing. Which are you using? • Absolute Pricing for CustomersMultiple CurrenciesMultiple PricesQuantity PricingPricing GroupsPrice Levels and Customers
k
@battk - Price Levels and Customers
b
the pricing join is for use with the Pricing Sublist / Pricing Matrix
use the
Pricing Item
and
Item Pricing
related columns from a customer search to get information related to Item Pricing
you can probably get the same information using a pricing search
k
So do a customer search by customer id to get the pricelevel id?
Actually, we are using the pricing sublist and matrix…
Sorry about that. I confused myself
b
probably easier if you make the search in the ui first
so that you can match columns to the sublist on the item
or customer
or whatever you are trying to do
there are lots of pricing features in netsuite, which is why i gave the list up front
k
I have a multi select field on an item record for “Upsell Items”. I am passing the itemid and custid to the suitelet to then retrieve the items in this multi-select field, and send back the required markup to the item detail template.
The gist:
Copy code
var itemID = request.getParameter('itemid');
    var custId = request.getParameter('custid');
    var stCallbackFunction = request.getParameter('callback');
    //nlapiLogExecution('DEBUG', 'Item IDs sent to suitescript: ', JSON.stringify(itemID));

    if (itemID == null) {
        response.write('URL parameter required: itemid <br> optional parameter: callback');
        return;
    }
    if (custId == null) {
        response.write('Customer ID parameter required: custid');
        return;
    }
    nlapiLogExecution('DEBUG', 'custId', custId);
    nlapiLogExecution('DEBUG', 'ITEM ID query string:', itemID);
    var filters = new Array();
    filters[0] = new nlobjSearchFilter('internalid', null, 'anyof', itemID);

    if (custId != 0) {
        filters[1] = new nlobjSearchFilter('customer', 'pricing', 'is', custId) // Getting the prices for a particular customer
    }
    

    var columns = new Array();
    columns[0] = new nlobjSearchColumn('itemid');
    columns[1] = new nlobjSearchColumn('parent');
    columns[2] = new nlobjSearchColumn('type');
    columns[3] = new nlobjSearchColumn("custitem_upsell");

    var searchresults = nlapiSearchRecord('item', null, filters, columns);
b
you want to use the pricing join related columns
again, my advice remains
k
What do you mean by that?
like this
filters[1] _=_
new
_nlobjSearchFilter_('customer', 'pricing', 'is', custId)
b
make the search in the ui
filters[1] _=_
new
_nlobjSearchFilter_('customer', 'pricing', 'is', custId)
is a filter, not a column
the pricing join has columns that you would want to use to find your matching price
your code should be getting the price from those columns
k
Ok, Ive never done a pricing join in Netsuite search. … I think I have some research to do.
b
its usually a pretty simple process, add all the columns from the join and see what you get
preferably on one item
once again, start in the ui so you can see the data you get