How can we make a SuiteQL query to find a Sales Or...
# ask-stanley-ai
j
How can we make a SuiteQL query to find a Sales Order by the customer's phone number?
c
AI generated answer (using internal Slack threads):
To make a SuiteQL query to find a Sales Order by the customer's phone number, you would need to join the
Transaction
table with the
Entity
table (which contains customer information including phone numbers) on the
Entity.ID
field. Here is a basic example of how you might structure this query:
Copy code
sql
SELECT 
    Transaction.ID,
    Transaction.TranID AS SalesOrderID,
    Transaction.TranDate AS OrderDate,
    Entity.Phone AS CustomerPhoneNumber,
    BUILTIN.DF( Transaction.Entity ) AS CustomerName,
    Transaction.OtherRefNum AS CustomerPONumber
FROM 
    Transaction
    INNER JOIN Entity ON
        ( Entity.ID = Transaction.Entity )
WHERE 
    ( Transaction.Type = 'SalesOrd' )
    AND ( Entity.Phone = 'YourPhoneNumberHere' )
In this query, replace
'YourPhoneNumberHere'
with the actual phone number you are searching for. This will return the Sales Order ID, Order Date, Customer Phone Number, Customer Name, and Customer PO Number for any sales orders associated with the given phone number. ****** 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.828485072
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820563495
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.819933236
Please provide your feedback on this answer.