Hi everyone. I'm trying to make a SuiteQL query to...
# general
j
Hi everyone. I'm trying to make a SuiteQL query to find the Item Fulfillment records that were created from a given Sales Order. I've tried querying using the createdFrom field on the Item Fulfillment but it tells me that field is an unknown identifier. Has anyone been able to do this? The query string I've tried is:
Copy code
SELECT * FROM Transaction WHERE CreatedFrom = '{Sales Order Id}' AND type = 'ItemFulfillment'
b
I think that something like this may be what you are looking for?
Copy code
SELECT
    *
FROM
    Transaction
JOIN
    PreviousTransactionLink ON
        PreviousTransactionLink.nextdoc = Transaction.id
WHERE
    recordType = 'itemfulfillment'
    AND
    PreviousTransactionLink.previousdoc = '{SalesOrderID}'
j
@Bailey Feldewerd That is returning exactly what I was looking for. Thank you so much!! I hadn't read anywhere about the PreviousTransactionLink. Awesome. Thank you.
Sorry to have to ask a follow-up question, but do you know how we can get a tracking number that's on the Item Fulfillment record? It's not in the response to a regular GET request by its ID.
b
Are you using the Rest API?
j
Yes
I did a GET request to /record/v1/itemFulfillment/{the Id of one of the returned Item Fulfillments}
b
I think if you do the following you can get the packages /record/v1/itemFulfillment/{the Id of one of the returned Item Fulfillments}/package
j
I tried that and /shipmentPackage too and both return no items. I've never been able to get requests to the urls in those links fields like those to return stuff.
b
Hmm, I'm not too familiar with the Rest API.
j
All good! Thanks for being helpful and trying when you didn't have to.
t
@John Phillips This might also help you?
SELECT t0.id AS HeaderId,t5.packagetrackingnumber AS packagetrackingnumber
FROM TRANSACTION t0
LEFT JOIN ItemFulfillmentPackage t5 ON t5.itemfulfillment = t0.id
WHERE t0.type = 'ItemShip'
220 Views