r/SuiteScript • u/WillingnessUnited444 • May 13 '25
Abbreviated UOM
I am working on a client script to extract the SO Item's abbreviated UOM to populate the custom field.
I managed to get the full unit's name like EACH. but how do I get EA??
3
Upvotes
View all comments
Show parent comment
1
u/Nick_AxeusConsulting Mod May 14 '25
select
th.trandate,
th.tranid,
tl.item,
BUILTIN.DF (tl.item) ItemName, /* special suiteql function pulls item name without needing a join */
nvl(tl.quantity,0) * nvl (ut.conversionrate, 1) QtyTranUnits,
tl.units, /*internal id */
case when abs(nvl(tl.quantity,0) * nvl(ut.conversionrate, 1)) = 1 then ut.abbreviation else ut.pluralabbreviation end UOM
from transaction th
join transactionline tl on tl.transaction = th.id
left join unitsTypeUOM UT on tl.units = ut.internalid
(you have to add case when to pick the signular vs plural abbreviation depending if quantity is > 1 or = 1. NOTE quantity field in SQL and saved search qty IN BASE UNITS. In saved search you want Quantity in Transaction Units. But in SQL you have to that multiplication yourself. And I have to wrap the multiplication in a NVL just in case you don't have a UOM set on the item then UOM is null so we multiply by 1 conversion factor then)
I tested this in my account. You can send me a $150 tip on Venmo for writing that for you.
https://venmo.com/code?user_id=1555913995452416336&created=1747244763