Why is TransactionLine.quantity returning -1 on a ...
# ask-stanley-ai
s
Why is TransactionLine.quantity returning -1 on a suiteql query of sales orders
c
AI generated answer (using internal Slack threads):
The TransactionLine.quantity is returning -1 on a SuiteQL query of sales orders because the quantity value is being returned in base units, not transaction units. This is a common occurrence when dealing with items that are ordered in packs or dozens. To get the correct quantity as shown on the sales order, you will need to convert the base units to the transaction units. This can be done using the
conversionrate
from the
unitstypeuom
table. For example, if you have an item that is ordered in dozens, the base unit quantity might be 6000 (which is 500 dozens). To get the quantity in dozens, you would divide the base unit quantity by the conversion rate (in this case, 12). As for the rate, it also differs by the factor of the conversion rate. When you divide the quantity by the conversion rate, you should multiply the rate by the same conversion rate to offset it. Here is an example of how you can do this:
Copy code
javascript
var baseUnitQuantity = 6000; // The quantity in base units
var conversionRate = 12; // The conversion rate for dozens

var transactionUnitQuantity = baseUnitQuantity / conversionRate; // The quantity in transaction units
The
conversionrate
can be found on the
unitstypeuom
table. The id of the units from your transaction is the
internalid
referenced on that table. You can find it under "uom" in the Units Type Records Catalog entry. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.82558012
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821870089
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813992083
Please provide your feedback on this answer.