The CreatorCon Call for Content is officially open! Get started here.

Is it possible to show/hide help text using client script?

vintotz
Tera Contributor

my intention is that when a users click a checkbox a helptext will be displayed. i have tried this example from serviceNow Guru, but it only collapse and expand the helptext.

Show/Hide Service Catalog Variable Help Text - ServiceNow Guru

2 REPLIES 2

Kushagra Mehrot
Kilo Guru

Hi Vin,



try using the same code in an onchange script for the check box variable!


Yes!   Servicenow keeps changing their dom so this code will work in Geneva but not Fuji.   We created a UI script so we can call a custom function instead of managing it on every client script;


Then you can use customToggleHelp('variablename'); to toggle


//ui script


//global: true


//active: true


function customToggleHelp(varname) {


  try{


  if(g_form.getTableName() == "ni"){


  customHelp(varname, 'slide');


  } else {


  taskCustomHelp(varname);


  }


  }catch(e){


  console.error('Error toggling Help');


  }




}




function customHelp(varname, action){


  var myVar1 = g_form.getControl(varname);


  myVar1 = 'question_help_IO_' + myVar1.id.split(':')[1].split('_')[0] + '_toggle';


  var element = document.getElementById(myVar1);


  _toggleIcon(element, "icon-vcr-down", _getVcrIconClass());


  if (action.toLowerCase() == 'slide'){


  $j("#" + element.id + "_value").slideToggle();


  }


  if (action.toLowerCase() == 'slidedown'){


  $j("#" + element.id + "_value").slideDown();


  }


  if (action.toLowerCase() == 'slideup'){


  $j("#" + element.id + "_value").slideUp();


  }


  _frameChanged();


}




function taskCustomHelp(varname){


  g_form.nameMap.map(function(i){


  if(i.prettyName == varname){


  var realID = i.realName;


  var a = $j('#question_help_ni_VE'+realID+'_toggle')[0];


  toggleVariableHelpText(a);


  return;


  }


  });


}