Does anyone know a way to get SuiteQL to behave th...
# suiteql
j
Does anyone know a way to get SuiteQL to behave the same within SuiteScript as it does when running through the RestAPI? I naively thought that is my SQL ran in Rest it would also run in SuiteScript but apparently not. In rest I can query for
taxrate1
on
transactionLine
but in SuiteQL the same query gives the following error
Copy code
Field 'taxrate1' for record 'transactionLine' was not found. Reason: NOT_EXPOSED - Field is marked as internal for channel SEARCH
Assuming it's not possible to get them behave the same does anyone know how I can get taxrate1 at a transaction line level from within SuiteQL?
e
In SuiteQL the tax information is a line on its own
Copy code
SELECT * FROM transactionline WHERE taxline = 'T'
c
I've seen something weird like this and it has been a permissions issue but it never says its a permissions issue. If you query is working in one spot and not the other that's probably it.
j
Thanks @Edgar Valdes unfortunately I need to the tax rate (or amount) at an individual line level rather than for the whole transaction 😞
@creece that was my first thought but as I am running the script as Administrator I am guessing this is not the issue.
e
The query I posted is at the line level, from the table
transactionline
j
@Edgar Valdes it is but if I have 10 lines of actual items that all have a tax rate of 20% then I would only get one taxline. If I have 8 items at 20% and 2 items at 0% then I would get two taxlines (at least one our system using the legacy tax). There is no one to one match of tax lines to item lines. As I only needed the net value I have managed to use the foreignamount field which does exist. The reason I was struggling was that Netsuite implemented discounts as a separate line item for us so the line itself has the full price and then the line below has the amount of the discount and I needed a discounted net price. What is really weird though, and my assumption was always that SuiteQL was just access to the underlying tables in the Oracle database, is that if you do a
Copy code
select TL.*
from transactionLine TL
where TL.transaction = 123
you will get taxrate1 back in the result but if you do
Copy code
select TL.*, TL.taxrate1
from transactionLine TL
where TL.transaction = 123
you will then magically get the tax rate returned correctly 🤷‍♂️ BUT this only works when using the REST API to call the SuiteQL. If you do the same working query using the N/Query module then it will complain about the taxtate1 field. I include all this information here in case anyone else has issues with "missing" fields when moving a query between SuiteScript and REST.
e
Yep, thats a problem with NetSuite, different contexts have different fields exposed/named, etc