Without scripting, is it possible to show the conv...
# general
l
Without scripting, is it possible to show the conversion rate of the UOM selected in the transaction lines? I tried sourcing and filtering ina custom field but it doesn't seem to be possible.
m
No it’s not possible I usually have a workflow store the sales unit conversion rate on the item record then source that into transactions But the WF needs to have a condition for each unit Like IF sale unit is case of 6 then set value to 6 If you have a big UOM table that’s not ideal I’ve heard scripting the units table can be tricky as it’s not easy to get values from it but I could be wrong
l
I will try that in the meantime. Thanks
Our Units are consistently named as XXX <units>. Ex. Carton 10, Inner 192, etc.
So I guess I can add a formula where it says grab the text from the right and stop at the first single space?
m
Yes like use TO_NUMBER(substr(instr(‘ ‘,{unit}),20))
s
@Luis @MGBC All transaction lines have a hidden field "unitconversionrate". Client script can access this field on postsourcing of the item record. You can also create a non-stored decimal field with the default value {unitconversionrate}. Of course the downside is, it's not shown until the record is saved. Other calculations at line level can access the hidden field as well if you need to do other things with it (like an alternative rate etc...)
I also have a library function I use routinely for access the conversions for a particular units type. This grabs all the relevant data for all conversions. Generally I would use this on save of a item record and store the conversions there. On clients scripts I generally call this via a Suitelet to avoid any permission issues.
Copy code
/**
 * 
 * @param unitType internal id of the base units type 
 * @returns {{uomLines: *[], uomLineCount: *}|null}
 */
function getUnitData(unitType) {
    if (!unitType) return null;
    var baseUnitRecord = record.load({
        type: "unitstype",
        id: unitType
    });
    var unitData = {
        uomLineCount: baseUnitRecord.getLineCount({sublistId: "uom"}),
        uomLines: []
    };
    for (var line = 0; line < unitData.uomLineCount; line++) {
        var uom = {
            id: baseUnitRecord.getSublistValue({sublistId: "uom", line: line, fieldId: "internalid"}),
            inuse: baseUnitRecord.getSublistValue({sublistId: "uom", line: line, fieldId: "inuse"}),
            name: baseUnitRecord.getSublistValue({sublistId: "uom", line: line, fieldId: "unitname"}),
            abbreviation: baseUnitRecord.getSublistValue({sublistId: "uom", line: line, fieldId: "abbreviation"}),
            pluralname: baseUnitRecord.getSublistValue({sublistId: "uom", line: line, fieldId: "pluralname"}),
            pluralabbreviation: baseUnitRecord.getSublistValue({sublistId: "uom", line: line, fieldId: "pluralabbreviation"}),
            conversionrate: baseUnitRecord.getSublistValue({sublistId: "uom", line: line, fieldId: "conversionrate"}),
            baseunit: baseUnitRecord.getSublistValue({sublistId: "uom", line: line, fieldId: "baseunit"})
        };
        unitData.uomLines.push(uom);
    }
    return unitData;
}
l
@Stefan Reeder that's very handy. Thank you!