SuiteScript N/search on Transaction Allocated Demand

I’m revamping the document generated on Print BOM for work order. I’ve created a before load user event script to search for operation tasks related the work order, then save them to a field  and render on the AdvancedPDF. Works great.

I’d also like to print the transaction details for all allocated demand associated with the work order. I can capture the information in a saved search, but when I try to do this in a script I get NULL for all the results fields on the allocated demand join. Are order allocations open to N/search?

In the below code, the first column populated as expected, second generates NULL. No errors thrown.

var transactionSearchObj = search.create({
   type: "transaction",
   settings:[{"name":"consolidationtype","value":"ACCTTYPE"}],
   filters:
   [
      ["internalid","anyof",recordId], 
      "AND", 
      ["mainline","is","T"]
   ],
   columns:
   [
      search.createColumn({name: "tranid", label: "Document Number"}),
      search.createColumn({
         name: "order",
         join: "allocatedDemand",
         label: "Document"
      })
   ]
});

 

Rookie Asked on May 3, 2024 in SuiteScript.
Add Comment
1 Answer(s)

Allocated Demand is joined to transactionLine, not sure Main Line = true  would work.

 

Try SuiteQL:

const QUERY_RESULTS = query.runSuiteQL({
query: `
SELECT
transaction.tranid,
allocatedDemand.order
FROM
transaction
LEFT OUTER JOIN transactionLine ON transaction.id = transactionLine.transaction
LEFT OUTER JOIN allocatedDemand ON transactionLine.id = allocatedDemand.tranline
WHERE
transaction.id = '${recordId}'
`}).asMappedResults(); // runs the query and converts to an array of objects

https://<accountid>.app.netsuite.com/app/recordscatalog/rcbrowser.nl?whence=#/record_ss/transaction/transactionLines?fieldId=allocatedDemand

Rookie Answered on May 8, 2024.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   SuiteMigration   Become a Sponsor