简体   繁体   中英

NetSuite: Retrieve a value from a popup/subrecord

Thanks for clicking in.

On the Customer record within the Address subtab I have a sublist with addresses. On each line there's a button for edit . (See first picture)

Clicking edit will bring up a popup window with some fields that can not be seen in Field Explorer. It is one of these fields I would really like to retrieve the value from. (See second picture)

See the third picture to see how the record of the field I want to retrieve looks.

I've tried to both load the customer record and to use lookupFields . But the field I want can't be accessed through just the customer record. Looking at the field record it says that it is for record of type Address . But it says it's a subrecord in record browser, and I don't really know how to access it.

Do I need to create a search in order to get to it? Or is a better way to use SuiteQL?

I'm still a bit new to NetSuite and haven't really done anything with SuiteQL yet. So any help and guidance is very much appreciated.

Address Sublist地址子列表

Popup

弹出窗口

Field场地

There are different options.

  1. When you loaded the customer record, you should load the address sublistrecord to access that value.
define(['N/record'], function(record) {

  var myRecord = record.load({
    type: record.Type.CUSTOMER,
    id: INTERNALID_OF_YOUR_CUSTOMER
  })

  for (var line = 0; line < myRecord.getLineCount({}); line++) {
    var address = myRecord.getSublistSubrecord({ sublistId: 'addressbook', line: line, fieldId: 'addressbookaddress' })
    var accountNo = address.getValue({ fieldId: FIELDID_OF_YOUR_CUSTOM_FIELD })
  }

})

  1. Use the N/search module
define(['N/search'], function(search) {
  
  var mySearch = search.create({
    type: search.Type.CUSTOMER,
    columns: [
      'internalid',
      'entityid',
      'companyname',
      { join: 'Address', name: 'city' },
      { join: 'Address', name: FIELDID_OF_YOUR_CUSTOM_FIELD },
    ],
    filters: [ 'internalid', search.Operator.IS, INTERNALID_OF_YOUR_CUSTOMER ]
  })
  
  mySearch.run().each(function(result) {
    ...DO SOMETHING
    return true;
  })

})

You need to load the subrecord for getting the values of address.You can use API recordObj.getCurrentSublistSubrecord . Here is the code how i have used to get the values:-

1- First load the customer record in script.

var customerObj = record.load({
             type: record.Type.CUSTOMER,
             id: customerRecordId,
             isDynamic:true
         });
 var addressSubrecord = customerObj.getCurrentSublistSubrecord({
         sublistId: 'addressbook',
         fieldId: 'addressbookaddress'
         });
        addressSubrecord.getValue({
             fieldId: 'addr1',
             value: linedata1.address1
         });

         addressSubrecord.getText({
             fieldId: 'country'
         });
         
         addressSubrecord.getValue({
             fieldId: 'addr2'
         });
         addressSubrecord.getValue({
             fieldId: 'zip'
         });

2-Put inside for loop if it is according to line using API and add line as well.

var numLines = objRecord.getLineCount({
    sublistId: 'addressbook'
});

You can get all the data using their field id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM