This topic contains 1 reply, has 0 voices, and was last updated by seifer 7 years, 12 months ago.

  • Author
    Posts
  • #5967

    seifer

    Hi everyone

    I’m building a shipping integration and have run into a problem with Custom Address Fields.

    I’m trying to accomplish two different ways of accessing the same data. Access the Custom Address Field ‘custrecord_street_number’ from a Client Script (validate field, or field changed.)
    Access the Custom Address Field ‘custrecord_street_number’ from a User Event Script (before load, and before submit.)

    On an Item Fulfillment I am able to access the currently selected address by using

    nlapiGetFieldValue(‘shipaddr1’) / shipaddr2 / shipcity / shipstate / etc

    But this only works for default NetSuite fields.

    Custom address fields are not stored on the parent record at all.

    I’ve read that I need to use the nlobjRecord.viewSubrecord() function to get the ‘shippingaddress’ body field but it doesn’t seem to work.

    According to NetSuite documentation (Page 1229 of SuiteScript Developer & Reference Guide 2015.2)

    “SuiteScript and SuiteFlow Impact of Version 2014 Release 2 Address Customization Changes

    … However, you need a different solution for code that sets values of fields that are in the parent

    record, because code on the address form does not have access to the parent record. You can

    modify this type of code within the client event script [emphasis added] that is deployed to the parent record type,

    setting it to fire on a Field Changed event on the address text field that is available to the parent

    record. Field Changed events on address text fields fire when changes to the address subrecord

    are committed. The Field Changed code can load the address subrecord [emphasis added], check which address

    fields have changed, and set parent field values accordingly.”

    So, I went ahead and created a client script that has a field changed function.

    Tried the following code:

    Code:
    function testfieldchange(type,name) {
    if(name == ‘shippingaddress’) {
    var subrec = nlapiViewSubrecord(‘shippingaddress’);
    }
    }
    And resulted in “SSS_INVALID_FIELD_ON_SUBRECORD_OPERATION”

    In a User Event before submit script I tried this code:

    Code:
    var rec = nlapiGetNewRecord();
    var subrec = rec.viewSubrecord(‘shippingaddress’);
    And that resulted in subrec == null

    The only way I’ve made the viewSubrecord command work is by loading an existing record in a Suitelet script, as follows:

    Code:
    var rec = nlapiLoadRecord(‘itemfulfillment’,1000);
    var subrec = rec.viewSubrecord(‘shippingaddress’);
    That works, and allows me to execute rec.getFieldValue(‘custom-field-name’)

    Any ideas how I can make this work for UE Before Load, UE Before Submit, and Client Script?

    Thanks,

    Kane
    This is a cached copy. Click here to see the original post.

  • #5968

    seifer

    PS. I can’t just workaround this by looking up the address on the Customer Record because sometimes the addresses are custom and not stored on the customer’s record.

You must be logged in to reply to this topic.