Caiman
02/11/2025, 3:27 PMtransactionLine
table when using the query module’s query.create()? I’m creating a query of type query.Type.TRANSACTION
and try to join transactionLine
but can’t seem to get it to work properly.
I can’t use suiteQL because i want to add the query object to a pdf renderer and it only accepts query.Query objects, unless someone knows how to create such an object using suiteQL?alien4u
02/11/2025, 4:58 PMconst oWOQuery = query.create({ type: "transaction"});
const oTranLines = oWOQuery.autoJoin({
fieldId: "transactionlines"
});
erictgrubaugh
02/11/2025, 6:56 PMrenderer.addQuery
only allows a Query
instance, then you can always use renderer.addCustomDataSource
instead to source your data from wherever you likeCaiman
02/11/2025, 7:22 PMCaiman
02/11/2025, 7:22 PMalien4u
02/11/2025, 7:24 PMtransactionlines
not transactionline
if I'm not mistaken.Caiman
02/11/2025, 7:26 PMerictgrubaugh
02/11/2025, 7:27 PMCaiman
02/11/2025, 7:29 PMconst itemsQuery = query.create({
type: query.Type.TRANSACTION
});
itemsQuery.columns = [
itemsQuery.createColumn({
fieldId: 'id'
})
];
const transactionLineJoin = itemsQuery.autoJoin({
fieldId: 'transactionLine'
});
transactionLineJoin.columns = [
transactionLineJoin.createColumn({
fieldId: 'item',
alias: 'job'
})
];
itemsQuery.condition = itemsQuery.createCondition({
fieldId: 'id',
operator: query.Operator.EQUAL,
values: invoiceId
});
const resultSet = itemsQuery.run();
const results = resultSet.results;
log.debug({title: `onRequest`, details: `result: ${JSON.stringify(results)}`});
Caiman
02/11/2025, 7:30 PMresult: [{"values":[2748051]}]
which is corrent, 2748051 is the id of the invoice i’m filtering onCaiman
02/12/2025, 2:15 PMerictgrubaugh
02/12/2025, 2:33 PMtransactionLineJoin.columns = [
transactionLineJoin.createColumn({
fieldId: 'item',
alias: 'job'
})
];
You're creating this Column
correctly, but I suspect you need to add it to itemsQuery.columns
, not transactionLineJoin.columns
erictgrubaugh
02/12/2025, 2:41 PMtransactionLines
, as Alien said. Those two changes make your code run as I expect in my accountCaiman
02/12/2025, 4:05 PM