Does anyone know if it is possible to reach the `t...
# suitescript
c
Does anyone know if it is possible to reach the
transactionLine
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?
a
Copy code
const oWOQuery = query.create({ type: "transaction"});

const oTranLines = oWOQuery.autoJoin({
    fieldId: "transactionlines"
});
e
If the problem is that
renderer.addQuery
only allows a
Query
instance, then you can always use
renderer.addCustomDataSource
instead to source your data from wherever you like
c
@erictgrubaugh That is indeed the problem and I think I’ll have to go with your suggestion. I still think it is very odd that you can’t reach the transactionLine table with a non-suiteql query…
@alien4u Thank’s but that is not working either.
a
Is
transactionlines
not
transactionline
if I'm not mistaken.
c
I’m afraid neither are working for me
e
You'll probably need to share your full code. You can absolutely reach the Transaction Line by joining to the Transaction
c
Copy code
const 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)}`});
the log at the very end is giving me
result: [{"values":[2748051]}]
which is corrent, 2748051 is the id of the invoice i’m filtering on
@erictgrubaugh did you get a chance to look at my code?
e
Copy code
transactionLineJoin.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
Also the Join Name is
transactionLines
, as Alien said. Those two changes make your code run as I expect in my account
c
Thank a lot @erictgrubaugh that made the trick! 👍🏻
1