- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-18-2022 05:33 AM
Hiii
I need to hide a field when a new record is created (in the other cases it has to be shown). And I want to avoid doing a client script. So I need to know if I can make a script in an UI Policy to do this. I understand that newRecord() cannot be used in the UI Policy, and I also tried "Created by is Empty" and "Created is Empty" but it doesn't work. Any ideas?
Solved! Go to Solution.
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-18-2022 05:45 AM
Hi Rocio,
You can do it with a script in either a UI Policy or a script include. You need to use the isNewRecord() function. Something like this:
if (g_form.isNewRecord() {
g_form.setVisible("<your field>", false);
}
else {
g_form.setVisible("<your field>", true);
}
Remember if you the field you are hiding is also set to mandatory you need to turn that off before setting visible to false.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-18-2022 05:41 AM
Hello Rocio,
You can use a Client script and validate g_form.isNewRecord().
Or you can validate if sys_id is different from -1 (records that are not yet saved have sys_id = -1, that is always a way to check if it is a new record).
Hope this helps!!
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-18-2022 05:45 AM
Hi Rocio,
You can do it with a script in either a UI Policy or a script include. You need to use the isNewRecord() function. Something like this:
if (g_form.isNewRecord() {
g_form.setVisible("<your field>", false);
}
else {
g_form.setVisible("<your field>", true);
}
Remember if you the field you are hiding is also set to mandatory you need to turn that off before setting visible to false.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-07-2024 02:08 AM
it's hiding the field but still gap is there in the form where that field was.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-09-2024 10:36 PM
Yes, if you use g_form.setVisible(), it hides the field but retains its space in the form layout. If you want to remove the field completely, including its space, you should use g_form.setDisplay('field_name', false);. This will not only hide the field but also remove the gap it occupies.