This topic contains 2 replies, has 0 voices, and was last updated by chris.wallace 8 years, 2 months ago.

  • Author
    Posts
  • #1823

    chris.wallace

    Encountered a huge issue today trying to create customer records on sandbox, which I believe has 2016.2 — apparently addressbook values aren’t being respected.

    I am able to run the code fine on 2016.1 Production, but getting UNEXPECTED_ERROR on 2016.2:

    Code:
    {“type”:”error.SuiteScriptError”,”name”:”UNEXPECTED_ERROR”,”message”:null,”stack”:[“(N/record/recordService)”,”(adhoc$-1$debugger.user:29)”,”(adhoc$-1$debugger.user:6)”],”cause”:{“type”:”internal error”,”code”:”UNEXPECTED_ERROR”,”details”:null,”userEvent”:null,”stackTrace”:[“(N/record/recordService)”,”(adhoc$-1$debugger.user:29)”,”(adhoc$-1$debugger.user:6)”]},”id”:””}
    Here’s code from another thread here as a known working example running in debugger:

    Code:
    /**
    * @NApiVersion 2.x
    * @NScriptType Restlet
    * @NModuleScope SameAccount
    */
    require([‘N/email’, ‘N/error’, ‘N/file’, ‘N/https’, ‘N/record’, ‘N/runtime’, ‘N/search’, ‘N/transaction’, ‘N/log’],
    /**
    * @param {email} email
    * @param {error} error
    * @param {file} file
    * @param {https} https
    * @param {record} record
    * @param {runtime} runtime
    * @param {search} search
    * @param {transaction} transaction
    */
    function (email, error, file, https, record, runtime, search, transaction, log) {

    var entity = record.create({type: ‘customer’, isDynamic: true});

    entity.setValue({fieldId: ‘companyname’, value: “test company”});
    entity.setValue({fieldId: ‘phone’, value: “(910) 867-5309”});
    entity.setValue({fieldId: ’email’, value: “test@email.com”});
    entity.setValue({fieldId: ‘subsidiary’, value: “9”});

    entity.selectNewLine({sublistId: ‘addressbook’});
    entity.setCurrentSublistValue({sublistId: ‘addressbook’, fieldId: ‘label’, value: “Test label”});
    var address = entity.getCurrentSublistSubrecord({sublistId: ‘addressbook’, fieldId: ‘addressbookaddress’});
    address.setValue({fieldId: ‘country’, value: ‘US’});
    address.setValue({fieldId: ‘addressee’, value: ”});
    address.setValue({fieldId: ‘addr1’, value: ‘12345 Main Street’});
    address.setValue({fieldId: ‘addr2’, value: ‘addrline2’});
    address.setValue({fieldId: ‘city’, value: ‘Austin’});
    address.setValue({fieldId: ‘state’, value: ‘TX’});
    address.setValue({fieldId: ‘zip’, value: ‘78702’});
    entity.commitLine({sublistId: ‘addressbook’});

    var entityid = entity.save();
    });
    Can someone tell me if they’re encountering the same error? Thanks!!
    This is a cached copy. Click here to see the original post.

  • #1824

    david.smith

    Not sure what the ‘label’ field is but why would it be separated from the other fields of the address?

    Here is how I’m setting my address lines in one of my RESTLets. I have to look up the country and state but otherwise this works for me.

    Code:
    var addr = [
    “addr1”,
    “addr2”,
    “city”,
    “state”,
    “zip”,
    “country”
    ];

    // **** OTHER CODE BLOCK ****

    // set the address
    recordObj.selectNewLine({
    sublistId: ‘addressbook’
    })
    for (var k=0; k<addr.length; k++) {
    var key = addr[k];
    if(key=='contry'){
    data[key] = countryLookup( data[key] );
    }
    if(key=='state'){
    data[key] = stateLookup( data[key] );
    }

    recordObj.setCurrentSublistValue({
    sublistId: 'addressbook',
    fieldId: key,
    value: data[key],
    ignoreFieldChange: true
    });
    };
    recordObj.commitLine({sublistId: 'addressbook'});

  • #1825

    chris.wallace

    Label is for the actual label of the sublist item for address on the customer record.

    Hopefully the release tonight for 2016.2 production goes smoothly. I’ll keep y’all updated.

You must be logged in to reply to this topic.