How to hide fields in suitescript?

by izaiah_collier , in category: Other , a year ago

How to hide fields in suitescript?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by alana , a year ago

@izaiah_collier 

In NetSuite SuiteScript, you can hide fields on a form using the setDisplayType() method. This method is available on both the nlobjField and nlobjSubListField objects.


To hide a field on a form, you can call the setDisplayType() method on the field object and pass in the value hidden as the argument. Here's an example of how to hide a field with the internal ID "custentity_my_custom_field":

1
2
var myField = form.getField('custentity_my_custom_field');
myField.setDisplayType('hidden');


If you want to show the field again, you can call the setDisplayType() method again and pass in the value normal as the argument:

1
2
var myField = form.getField('custentity_my_custom_field');
myField.setDisplayType('normal');


Note that hiding a field does not prevent the user from being able to access the data in that field through other means, such as scripting or saved searches. If you need to hide data from certain users, you may need to implement additional security measures.

Member

by vanessa , 3 months ago

@izaiah_collier 

To hide fields in SuiteScript, you can use the setDisplayType() method. Here's an example:

  1. Get a reference to the field you want to hide using getField() or getSublistField() method.
  2. Call the setDisplayType() method on the field object and pass 'hidden' as the argument.


Example to hide a field on a form:

1
2
var field = form.getField('field_id');
field.setDisplayType('hidden');


Example to hide a field on a sublist:

1
2
var sublistField = sublist.getSublistField('field_id');
sublistField.setDisplayType('hidden');


Make sure to replace 'field_id' with the actual internal ID of the field or sublist field you want to hide.


In case you need to show the hidden field again, you can use 'normal' as the argument:

1
2
field.setDisplayType('normal');
sublistField.setDisplayType('normal');


By using setDisplayType() method, you can control the visibility of fields based on your requirements.