This topic contains 1 reply, has 0 voices, and was last updated by starlingMark 5 years, 10 months ago.

  • Author
    Posts
  • #17772 Score: 0

    dbetlow
    • Contributions: 0
    • Level 1

    I have an interesting problem I’m trying to solve. The phone number of a subrecord address doesn’t show up on the transaction form as part of the address. Because UPS and Fedex require phone number when shipping, the user has to edit the sales order and edit the address in order to see the phone number field…

    I’d like to retrieve the phone number field from the subrecord shipping address and display it as a transaction body field.

    The following code works for a client script. However, I don’t want the user to have to edit the record to see the phone number. I’d like to make this work as a User Event script, but it seems I can’t update the field in either a BeforeLoad or BeforeSubmit. The field doesn’t store a value, it is just used to display the value. I could make the field store a value, but then it would only work for transactions going forward, not previously created ones…

    Code:
    /**
    * @NApiVersion 2.x
    * @NScriptType ClientScript
    */

    define([ ‘N/record’ ],

    function(record) {

    function pageInit(context) {

    // Load the record.

    var rec = context.currentRecord;

    // Retrieve the subrecord.

    var subrec = rec.getSubrecord({
    fieldId: ‘shippingaddress’
    });

    // Create a variable and initialize it to the
    // value of the subrecord’s phone field.

    var phoneValue = subrec.getValue({
    fieldId: ‘addrphone’
    });

    rec.setValue({
    fieldId: ‘custbody37’,
    value: phoneValue,
    ignoreFieldChange: true,
    fireSlavingSync: true
    });

    // Print the value to the execution log.

    try {

    log.debug({
    title: ‘phone value’,
    details: ‘phone value: ‘ + phoneValue
    });

    } catch (e) {

    log.error({
    title: e.name,
    details: e.message
    });
    }
    }

    return {
    pageInit: pageInit
    }
    });
    This is a cached copy. Click here to see the original post.

  • #17773 Score: 0

    starlingMark
    • Contributions: 0
    • Level 1

    Have you considered having the field not store the value but populate it with a saved search? Details can be found in the NS help file here:

    https://system.na3.netsuite.com/app/…_N2830711.html

You must be logged in to reply to this topic.