difference between setVisible() and setDisplay() on g_form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2015 03:43 AM
Hi,
i just read the information about these two methods, both methods cannot hide mandatory fields with no value and the only difference i found is,
setDisplay()
If the field is hidden, the space is used to display other items. that means below field like, if sub status of the incident is not displaying then assignment group will display on that blank space.
setVisible()
If the field is hidden, the space is left blank.you can see the change on the form clearly.
But it is not suggestible to use these methods, instead of this just go for UI policies.
Regards,
Swamy.
- 47,309 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2024 05:32 AM
Hello @swamyk,
Both methods are used to hide the fields on the form using Client scripting, but setDisplay() will use the space once the field is invisible, also see the detailed information blow...
g_form.setVisible -
- Syntax - setVisible(String fieldName, Boolean display)
- This method is used to hide and show the particular field in the form.
- On desktop UI, the space is left blank when hidden.
- On Mobile or Service Portal UI, the space is filled in my other fields when hidden. This method cannot hide mandatory fields with no value.
- Use UI Policy rather than this method whenever possible.
Example -
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//If the page isn't loading
if (!isLoading) {
//If the new value isn't blank
if(newValue != '') {
g_form.setVisible('priority', false);
}
else
g_form.setVisible('priority', true);
}
}
g_form .setDisplay -
- Syntax - setDisplay(String fieldName, Boolean display)
- We can maintain the hidden field space with using the setVisible method but with setDisplay, we won’t have space in between the hidden field.
- This method cannot hide a mandatory field with no value.
- If the field is hidden, the space is used to display other items. Whenever possible, use a UI policy instead of this method.
Example -
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//If the page isn't loading
if (!isLoading) {
//If the new value isn't blank
if (newValue != '') {
g_form.setDisplay('priority', false);
}
else
g_form.setDisplay('priority', true);
}
}
If my answer has helped with your question, please mark my answer as an accepted solution and give it a thumbs up.
Thanks & Regards,
Pranay Soni