- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 01:59 AM
Hi - on our incident records we pull through a custom field from the sys_user table, specifically from the record of the user in the caller_id field.
What I want to achieve is that this 'DaaS User' field will only show if the value of the true|false is true. If it returns false then it should not show on the Incident record.
I have tried the following client script which runs OnLoad;
function onLoad() {
if(u_daas_user == true){
g_form.setDisplay("u_daas_user", true);
}
else {
g_form.setDisplay("u_daas_user", false);
}
}
Unfortunately this doesn't seem to be doing the trick. Any ideas what I may be doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 04:14 AM
I've managed to get it working. Looks like there's an issue with ServiceNow client scripts returning Boolean variables. Followed the below to tweak it a little and it works. Thanks for your help!
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783585
function onLoad() {
var daas_user = g_form.getValue("caller_id.u_daas_user");
if(daas_user == 'true'){
g_form.setDisplay("caller_id.u_daas_user", true);
}
else {
g_form.setDisplay("caller_id.u_daas_user", false);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 02:41 AM
Or
g_form.setDisplay("u_daas_user", g_form.getValue("u_daas_user"));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 02:45 AM
The code doesn't seem to make too much sense. The script is trying to show/hide by the value of itself.