- 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:11 AM
Hi
Please use this code.
function onLoad() {
if(g_form.getValue("u_daas_user") == true){
g_form.setDisplay("u_daas_user", true); }
else {
g_form.setDisplay("u_daas_user", false); }
}
Thanks,
Please mark the answer correct and helpful. If solution is feasible.
Please mark the answer as helpful and correct.
Best Regards,
Rajat Choudhary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 04:05 AM
Thanks Rajat, this seems to be hiding the field okay when the result is false. However when it's true it also still seems to be hiding it so I'm not sure if it's reading the value correctly.
Also slight oversight on my side the variable is caller_id.u_daas_user
- 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 05:41 AM
Great to hear that
Always Happy to help.
Please mark the answer as helpful and correct.
Best Regards,
Rajat Choudhary