i'm attempting to update the base price of an item...
# suitescript
k
i'm attempting to update the base price of an item in suitescript. i see that inventory items have a sublist for each currency(?) which is a matrix of qty => price values? however, it's unclear to me whether i'm guaranteed that index 0 in the sublist is always the base price or, if not, how i determine which index i want to actually update i see in "accounting lists" that "Base Price" is given the list "Base Price Level", while other price levels are given the list "Price Level", so ... not fully sure what i'm supposed to do with that info šŸ˜…
a
This is a tricky business, complex topic; on top of that, the structure changes depending on features like multi-currency, etc. You need to invest some time reading this: • https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_1502207768.html#bridgehead_N3217049
k
i did read over that page previously. the account appears to have multi currency and quantity pricing enabled both
but my question is a little more basic; it's essentially: how do i identify which line item is the "base price" level
or, preferably, set its value without knowing which line it is
a
Untitled.js
With multi-currency the price level sublist for the base currency will be:
sublistId: 'price1',
You can explore that sublist with: • Record.getSublistFields(options) You can also use/try ^^^
k
i did that, but none of this identifies the sublist entry by its identity, just the text label
Copy code
rec.getSublistFields({sublistId: 'price1'})
(10) ['pricelevel', 'currency', 'pricelevelname', 'discount', 'discountdisplay', 'price_1_', 'price_2_', 'price_3_', 'price_4_', 'price_5_']

"pricelevel"
"currency"
"pricelevelname"
"discount"
"discountdisplay"
"price_1_"
"price_2_"
"price_3_"
"price_4_"
"price_5_"
a
You can find a sublist price level by id like this:
Copy code
oRec.findSublistLineWithValue({
    sublistId: 'price1',
    fieldId: 'pricelevel',
    value: pPriceLevelId
});
But you must know the ID.
k
Copy code
rec.getSublistValue({sublistId: 'price1', fieldId: 'pricelevelname', line: 0})
'Base Price'
the name is configurable though, so what i'm trying to do is "get the line that IS the base price level", not "get the line with the human text by the name `"Base Price"`"
it seems plausible that the base price level is always the first entry
a
The price level ID should not change once created, therefore the Base Price Level ID should be the same.
k
and it's clearly treated specially or different by netsuite
writing code based on "the value of the data at the time i wrote the code" seems ... brittle
😬
am i misunderstanding something about "Base Price"? one sec
this is what i see on "accounting lists"
and this is what i see on a test item
because the "List" is given as "Base Price Level" rather than "Price Level", i am understanding it to be different or special - significant to netsuite in some way - but perhaps that is incorrect?
a
All you need to worry about is that the ID of the Price level is something you would be able to find at the Item Pricing Sublist and therefore something you can update.
k
sure. just trying to determine how to get that id in a reliable way; specifically, the id that represents the default price when no price level is selected -- or, put another way, the "normal" price of the item
a
Base Price is special only in the sense that you can't delete it or inactivate it... and it will probably have the ID of 1 always... but I not 100% sure.
k
that's what it kinda seemed like, i was trying to verify if that's true šŸ™‚
a
The reliable way to get the ID is via Setup -> Accounting -> Accounting Lists - Price Level
k
(sorry, was on phone) i'm writing code, so like... "click some stuff in the ui" doesn't help me much šŸ˜‰ i expect there is probably an api that can list these things out, but what i don't know is what to use or what to tell it to get me the result i'm looking for
if i'm being fully diligent, i suspect that i need to do something like query the accounting lists for the list named "Base Price Level", though god knows what i do if it can have more than one record
b
its always the first price level with the id of 1
you can neither delete or inactivate it
though you can change its name, making searching by name less exact than choosing the one with the id of 1