1
votes

I would like to hide the ID 'custrecord_hrx_vendor_status_list' once item has selected in select box ( options ).

Here is my code. /** * @NApiVersion 2.x * @NScriptType ClientScript */

define(['N/ui/serverWidget', 'N/error'],

function (error) {

    function fieldChanged(context) {
        var currentRecord = context.currentRecord;
        var fieldId = context.fieldId;
        if( fieldId === 'custrecord_hrx_negotiation_type' ){
            var selectedType = currentRecord.getText(fieldId);
            console.log(currentRecord.getField('custrecord_hrx_vendor_status_list'));

            currentRecord.updateDisplayType({
                id: 'custrecord_hrx_vendor_status_list',
                displayType: serverWidget.FieldDisplayType.HIDDEN
            });
        }
    }

    return {
        fieldChanged: fieldChanged
    }


}

);

----HERE IS THE ERROR

enter image description here

2

2 Answers

7
votes

As the error message says, you are trying to load a module that is not available. You are writing a client script, and trying to load a module that is only for server-side scripts.

Additionally, N/currentRecord#CurrentRecord does not have a updateDisplayType() method.

The way to hide a field in a SS2.0 client script is:

currentRecord.getField({
  fieldId: 'custrecord_hrx_vendor_status_list'
}).isDisplay = false;
0
votes

N/ui/serverwidget Module doen not work in client script.you must use like this to hide currentRecord.getField( { fieldId: id } ).isDisplay = false;