Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

suitescript - NetSuite: Need to get value Of Landed Cost Category Line Field using Transaction Saved Search

I am trying to somewhat mimic NetSuite's Landed Cost feature using NetSuite's customization options (SuiteBuilder,SuiteScript etc.) and then further extend the functionality according to my requirements.

For this I need to in script, get value of "LANDED COST CATEGORY" line field of item sublist in the Transaction records (like Bill, Purchase Order etc.) using saved search.

But in a saved search I was unable to find any Column/scriptId which would give me value of LANDED COST CATEGORY line field. We ARE able to get this value using record.load().getValue() but I need this value from multiple transaction records and using this approach may cause performance issues. So, please can you tell how we can access this value using saved search.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't believe Netsuite exposes that field in saved searches at this time. This is the records browser in Netsuite listing all of the available search columns for Transaction searches. The internal id for that column is landedcostcategory, and that doesn't show up on the list.

However, if your goal is to get this information in SuiteScript, then you can use the 'N/query' module. Pull up one of your Purchase Orders, open the Javascript console (Ctrl+Shift+J) and try this:

require(['N/query'], (query) => {
  const suiteqlQuery = `SELECT 
                          transaction as transaction_id,
                          BUILTIN.DF(transaction) as transaction_name, 
                          BUILTIN.DF(item) as item_name,
                          item as item_id, 
                          landedcostcategory as landedcostcategory_id,
                          BUILTIN.DF(landedcostcategory) as landedcostcategory_name
                        FROM
                          transactionline
                        WHERE
                          transaction='<internal id of your PO here>'`;
  const results = query.runSuiteQL({query: suiteqlQuery}).asMappedResults();
  console.log(JSON.stringify(results, null, 2));           
  
  /*
    Example output for results:
    [
      {
        "transaction_id": "12345",
        "transaction_name": "Purchase Order #PO123456",
        "item_name": "My Favorite iPod",
        "item_id": 1234,
        "landedcostcategory_id": 1,
        "landedcostcategory_name": "Duties & Tariffs"
      }
    ]
  */
})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...