- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 06:27 AM
Hi,
I need to expand (alternatively display) the help text on variable A, when variable A has value X, and preferably also revert back when not true. I found this article:
https://community.servicenow.com/community?id=community_question&sys_id=7a24c329dbd8dbc01dcaf3231f9619c3&view_source=searchResult
but I can't seem to get it to work. Do I need to change some bit, since I need it for Service Portal UI?
Or has something changed since, it's a 2 yr old post?
Here is what I got from this post, please tell me what is wrong here:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var val =g_form.getValue('A');
if(val == 'X'){
var elems = document.getElementsByClassName('sc-help-text annotation-wrapper');
for (var i=0;i<elems.length;i+=1){
if (elems[i].style.display === 'none') {
elems[i].style.display = 'block';
}
}
}
}
Or maybe nothing is wrong with my script, but something else I'm completely missing..
Thanks in advance!
Annika
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 03:29 AM
I tried below script in my PDI and it works for me.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue=='admin'){
alert('test');
g_form.showFieldMsg('type_of_request','This is a test','info',true);
}
else{
g_form.hideFieldMsg('type_of_request');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 06:42 AM
DOM manipulation is not supported in service portal. Please refer below link
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 06:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 06:59 AM
Thanks! That explains it completely 🙂 Is there any smoother way to do this, than to display some sort of label variable with Cat. UI policy then?
Cheers,
Annika

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 09:13 AM
Try using field message, if that helps your need.
Thanks