This topic contains 4 replies, has 0 voices, and was last updated by egrubaugh 7 years, 8 months ago.

  • Author
    Posts
  • #1849 Score: 0

    JacksonP
    • Contributions: 0
    • Level 1

    I’m writing a client script and I’m trying to figure out how to change a field’s display type. Basically I’m making fields dependent on each other. Say I have 3 fields…

    If Field 1 is empty, field 2 and 3 are disabled to edit.

    If Field 1 contains something, I want to enabled field 2, but if Field 2 is empty, Field 3 Is still disabled…

    I figured it would be in the ‘N/record’ module, but I can’t find anything that will let me changed the Field’s Display type.

    Thanks for the help!
    This is a cached copy. Click here to see the original post.

  • #1850 Score: 0

    MChammaTX
    • Contributions: 0
    • Level 1

    Off the top I’m not sure. If I remember you could only disable fields in beforeLoad in SS 1.0, although my memory is fuzzy. Not sure if this is now possible in 2.0.

    My workaround faced with 1.0 was to use workflows as this was possible client side.

    Maybe others can provide better insight?


    JacksonP replied on 08/23/2016, 11:48 AM: I did find under fieldChanged in client scripts it specifically says ‘Disable or enable fields based on user input’

  • #1851 Score: 0

    khultquist
    • Contributions: 0
    • Level 1

    Nope, you cannot change the Field Display Type in a client script, only in a user event script.

    Consider using a Validate Field function for the dependent fields. You can build the same logic but it behaves a little differently in the UI.


    JacksonP replied on 08/23/2016, 12:48 PM: Alright, thanks for the help.

  • #1852 Score: 0

    michoel
    • Contributions: 0
    • Level 1

    Originally posted by khultquist

    View Post

    Nope, you cannot change the Field Display Type in a client script, only in a user event script..

    You definitely can do this, here is an example of making the ‘comments’ field enabled only if ‘companyname’ is not empty

    Code:
    /**
    * @NApiVersion 2.x
    * @NScriptType ClientScript
    */
    define([], function() {

    return {

    fieldChanged: function(context) {
    if(context.fieldId === ‘companyname’) {
    var record = context.currentRecord;
    var isDisabled = record.getValue({ fieldId: ‘companyname’ }) ? false : true;
    record.getField({ fieldId: ‘comments’ }).isDisabled = isDisabled;
    }
    }

    }

    });


    khultquist replied on 08/23/2016, 07:55 PM: Very cool, it’s time for me to learn SuiteScript 2.0

  • #1853 Score: 0

    egrubaugh
    • Contributions: 0
    • Level 1

    You should be able to disable/enable fields at will in a Client Script using the supported 1.0 nlapiDisableField method. It just takes the field ID and a Boolean as arguments; send in true to disable the field and false to enable it.

    Code:
    nlapiDisableField(‘custfieldid’, true);
    We use this several places in our SuiteApp with no issues.

You must be logged in to reply to this topic.