- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 08:00 AM
In my user table, I have created a section called 'Additional details', In that section I have 5 fields in it, I need to hide 2 of those 5 fields using client script. Can anyone help me on this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 08:08 AM - edited 04-02-2024 08:10 AM
Hi @Govind Bysani,
As you've specifically asked to hide the fields via a Client Script, leverage the g_form.setDisplay() method as shown within an onLoad Script: (Obviously you'll want to write the appropriate clause/syntax as to when to hide or not)
g_form.setDisplay('the_field_name_to_hide', false); //Enter the field name to hide within quotes
Please note, based on the execution order and call stack, best practice guides you to use a UI Policy.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 08:05 AM
Please use below sample script and modify accordingly:
var field1 = g_form.getControl('field1_sys_id'); // Replace 'field1_sys_id' with the actual sys_id of your field
var field2 = g_form.getControl('field2_sys_id'); // Replace 'field2_sys_id' with the actual sys_id of your field
// Check if both fields exist
if (field1 && field2) {
// Hide the fields
field1.style.display = 'none';
field2.style.display = 'none';
// Optionally, you can also hide the labels if needed
var label1 = g_form.getLabelOf(field1);
var label2 = g_form.getLabelOf(field2);
if (label1) {
label1.style.display = 'none';
}
if (label2) {
label2.style.display = 'none';
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 08:08 AM - edited 04-02-2024 08:10 AM
Hi @Govind Bysani,
As you've specifically asked to hide the fields via a Client Script, leverage the g_form.setDisplay() method as shown within an onLoad Script: (Obviously you'll want to write the appropriate clause/syntax as to when to hide or not)
g_form.setDisplay('the_field_name_to_hide', false); //Enter the field name to hide within quotes
Please note, based on the execution order and call stack, best practice guides you to use a UI Policy.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie