Having issues trying to get to the native {assembl...
# suiteql
p
Having issues trying to get to the native {assemblyitem} field on a Word Order. The field just doesnt seem to exist. If I replicate the same query via Saved search is exists. Perhaps a limitation on SuiteQL?
Copy code
SELECT 
id,
	startdate,
    transactionnumber,
--   assemblyitem,
    enddate,
  	BUILTIN.DF(entity) as Customer,
FROM 
	Transaction 
WHERE 
	( Type = 'WorkOrd' )
c
To get any item information, including the assembly item being built on a work order, you'll need the
transactionline
table. You can join on
transactionline.transaction = transaction.id
. In this case, you should filter by
mainline = 'T'
. For example:
Copy code
SELECT
  tran.id,
  tran.startdate,
  tran.transactionnumber,
  line.item,
  tran.enddate,
  BUILTIN.DF(tran.entity) as Customer,
FROM transaction AS tran

JOIN transactionline AS line
ON   line.transaction = tran.id

WHERE
  tran.type = 'WorkOrd' AND
  line.mainline = 'T'
p
@Clay Roper Thanks, the {assemblyitem} item is a Header field though. The lines are the components of the BOM, we need the header fields.
c
In SuiteQL, the distinction between "header" fields and others is different than in saved search. For a Work Order, the item on the main line is the assembly item being built, which is why the WHERE clause filters on
line.mainline = 'T'
. Feel free to try the query above for yourself to see - you can add
AND tran.id = xxx
where
xxx
is the internal ID of a Work Order whose assembly item id you know, so you can validate the results.
For what it's worth, there are several notable differences between the data model presented via Saved Search and those presented via SuiteQL query, and I would recommend you take some time to familiarize yourself with those differences.