vennila ramasamy
04/28/2023, 11:25 AMNathan L
04/28/2023, 11:31 AMvennila ramasamy
04/28/2023, 11:49 AMNathan L
04/28/2023, 2:25 PMvar queryString = `SELECT
item.itemid
, item.id
, item.displayname
, bomcomp.item
, itemcomp.itemid
, itemcomp.displayname
, bomcomp.bomquantity
, itemcomp.itemtype
, itemcomp.custitem_cmb_rollup_cost
, itemcomp.lastpurchaseprice
FROM assemblyitembom as assbom
JOIN item ON assbom.assembly = item.id
JOIN bom ON assbom.billofmaterials = bom.id
JOIN bomrevision as bomrev ON bomrev.billofmaterials = bom.id
JOIN bomrevisioncomponent as bomcomp ON bomcomp.bomrevision = bomrev.id
JOIN item as itemcomp ON bomcomp.item = itemcomp.id
WHERE assbom.assembly = item.id
AND bomcomp.item = itemcomp.id
AND assbom.billofmaterials = bom.id
AND bomrev.billofmaterials = bom.id
AND bomcomp.bomrevision = bomrev.id
AND (bomrev.effectivestartdate is NULL OR bomrev.effectivestartdate <= ?)`
var results = query.runSuiteQL({
query: queryString,
params: [stringDate]
});
So to walk through what I did, first i pulled your query string out into a variable and wrapped it in tick marks `` to be able to format it in a way thats a little easier to read.
Then i updated your FROM statement to add the joins in.
Then we just call the query the same way, but we just provide the newly created queryString variable into the function.Nathan L
04/28/2023, 2:28 PM