how to list all Purchase Orders that are having lo...
# ask-stanley-ai
m
how to list all Purchase Orders that are having location changes
c
AI generated answer (using internal Slack threads):
To list all Purchase Orders that are having location changes, you can use SuiteScript or SuiteQL to query the transaction records. In SuiteScript, you can use the
N/search
module to create a search. Here is a sample code:
Copy code
javascript
var search = require('N/search');
var purchaseOrderSearch = search.create({
   type: search.Type.PURCHASE_ORDER,
   filters: [
      ['location', 'noneof', '@NONE@'],
      'and',
      ['location', 'changed', '']
   ],
   columns: ['tranid', 'location']
});
var resultSet = purchaseOrderSearch.run();
resultSet.each(function(result) {
   log.debug({
      title: 'Purchase Order with Location Change',
      details: 'Purchase Order ID: ' + result.getValue('tranid') + ', Location: ' + result.getText('location')
   });
   return true;
});
This script will return all Purchase Orders where the location has been changed. In SuiteQL, you can use a SQL-like syntax to query the data. Here is a sample query:
Copy code
sql
SELECT T.id, T.tranid, L.name
FROM transaction T
JOIN location L ON T.location = L.id
WHERE T.type = 'PurchOrd' AND T.location IS NOT NULL AND T.location != ''
This query will return all Purchase Orders with a location. Please note that these are just examples and you may need to adjust the code or query to fit your specific needs. ****** 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.813574672
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.804834485
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.797782779
Please provide your feedback on this answer.