'Hide other field on field change - Suite Script 2.0
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
Solution 1:[1]
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;
Solution 2:[2]
N/ui/serverwidget Module doen not work in client script.you must use like this to hide currentRecord.getField( { fieldId: id } ).isDisplay = false;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | michoel |
Solution 2 | Sai Ananth |