/**
* @description search function to fetch the tax percent from the purchase order record
* @param {number} poRecordsId - purchase order internal id
* @return itemObj - object containing tax percentage
*/
function purchaseOrderDetails(poRecordsId) {
try {
let purchaseorderSearchObj = search.create({
type: "purchaseorder",
filters:
[
["type", "anyof", "PurchOrd"],
"AND",
["internalid", "anyof", poRecordsId],
"AND",
["mainline", "is", "F"],
"AND",
["cogs", "is", "F"],
"AND",
["shipping", "is", "F"]
],
columns:
[
search.createColumn({name: "line", label: "Line ID"}),
search.createColumn({
name: "rate",
join: "taxItem",
label: "Rate"
})
]
});
let searchResultCount = purchaseorderSearchObj.runPaged().count;
let itemObj = {}
if (searchResultCount > 0) {
purchaseorderSearchObj.run().each(function (result) {
let memberLine = result.getValue({
name: "line",
label: "Line ID"
})
let memberTax = result.getValue({
name: "rate",
join: "taxItem",
label: "Rate"
})
itemObj[memberLine] = memberTax;
return true
});
return itemObj;
}
} catch (e) {
log.error("error @ search function", e)
}
}