Make a field visible w.r.t a reference field when it contains nothing but not when form is loaded.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-03-2025 09:25 PM - edited ā02-03-2025 10:34 PM
Hi All,
I have a reference field in record producer which refers to company table and a string field also there named "other organization name" which is to be mandatory and visible when the Organization Name field contains no value.
But now the field is when form is loaded but I want the field to be visible when value changes . Also the company table contains empty records that means if I select empty record the Other Company field will not be visible. How to configure it when reference field value contains no value then the string value should visible but not when form is loaded.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-03-2025 10:36 PM
I have checked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-03-2025 10:38 PM
Hi @1_DipikaD ,
You can write below script in onchange client script. I have tested it and working fine. You can replace with your variable.
function onChange(control, oldValue, newValue, isLoading) {
var organisation = g_form.getReference('organisation').name;
if (organisation == '' || organisation == undefined) {
g_form.setDisplay('other_comapny', false);
} else {
g_form.setDisplay('other_comapny', true);
}
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-03-2025 10:44 PM
Hi @1_DipikaD ,
In this scenario, If you want the "Other Company Name" it will also be visible onLoad. You cannot hide it on onLoad and make it visible if "Company" is empty because it requires onChange but if they are not touching that particular variable it wont consider as onChange.
So, the alternative solution which I suggest you is, create one more variable i.e., "Company not listed" as a checkbox and if they select it you can display "Other Company Name" variable using UI Policy.
Please feel free to ask incase of any queries from the above solution.
Please mark it as correct if it resolved your issue.
Regards,
Deepika