does anyone know how to pull in fulfillments for a...
# general
m
does anyone know how to pull in fulfillments for a sales order based on the sales order id? Im trying to use SuiteScripts and for the life of me I can't link them to eachother with any of the default fields.
b
what does your attempts look like
m
var mySearch = search.create({ type: search.Type.ITEM_FULFILLMENT, columns: ["internalid", "tranid", "statusref", "status"], filters: ["createdFrom", "is", orderId], });
Sorry was in a meeting
b
looks like it should work
if it doesnt, then orderId is likely not an internal id
m
yeah. i think maybe createdFrom is not used anymore? It comes back blank.
const q = "SELECT Transaction.id " + "FROM Transaction " + "INNER JOIN TransactionLine ON TransactionLine.Transaction = Transaction.ID AND TransactionLine.MainLine = 'T' " + "INNER JOIN Transaction AS SalesOrder ON SalesOrder.ID = TransactionLine.CreatedFrom " + "WHERE SalesOrder.id =" + orderId + " AND Transaction.Type = 'ItemShip'";
this works but holy cow theres got to be a better way!
b
Michael - your saved search will work, but you can't use the "is" operator on the "createdFrom" field. You must use the "anyof" operator
1
and here is a simpler query that will just return the item fulfillment IDs:
"SELECT T.ID FROM Transasction T JOIN TransactionLine TL ON T.id = TL.transaction AND TL.mainline = 'T' WHERE TL.createdfrom = " + orderId
1
m
@Boban Dragojlovic Very appreciated!