Hi guys, does anyone know if there is a way to sho...
# suitescript
g
Hi guys, does anyone know if there is a way to show hidden fields in a form using a client script? I want to show some specific fields when the value of a field is changed.
n
For sure. You just get the field with record.getField then update the display type with field.updateDisplayType
Copy code
function updateFieldDisplayType(record, fieldName, displayType) {
        var field = record.getField({
            fieldId: fieldName
        });

        if (field) {
            field.updateDisplayType({
                displayType: displayType
            });
        }
    }
In your case you would have something like
Copy code
function fieldChanged(context) {
        var record = context.currentRecord;
        var fieldName = context.fieldId;

        if (fieldName === 'custpage_field_to_update') {
            updateFieldDisplayType(record, 'custpage_field_to_change_display', 'normal');
        }
    }
b
thats not how client script does it
Field.isDisplay is what you would use
👍 1
the one thing to know is that the field has to start off normally displayed
if it starts off hidden, you cant change it to be visible using suitescript
g
I am trying using this code, but even the isDisplay property is true, the fields are not showed. _for_(var i in arrFieldsToShow){ var field = _record.getField_({ fieldId : arrFieldsToShow[i] }); _field._isDisplay = true;
b
start the field off displayed
then hide it in the pageInit
g
Should it show as normal? Or does it also work if they are in-line or disabled?
t
doublecheck the permission level of the field..
b
i would recommend normal
p
Full control can be achieved by combination of: UES/SL (hide it be default):
Copy code
field.updateDisplayType({
    displayType : serverWidget.FieldDisplayType.NODISPLAY
});
CS (show/hide on demand):
Copy code
field.isDisplay = true;
❤️ 1
g
@Pavol I already coded your solution and it works just the way I want. Thank you very much for your help 😊
👍 2