Display More Information text when a field value is changed

kb22
Kilo Contributor

I know the onLoad script for automatically displaying More Information text, but was wondering if it's possible to only open it if a field is changed after opening i.e. type of request = 'delete'?

1 ACCEPTED SOLUTION

Your client script would watch the type_of_request variable. The (untested) script would look like this:



function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading || newValue == '') {


          return;


  }


if (newValue == 'delete') {


      var myVar = g_form.getControl('comments_note');


      if(myVar) {


                  var myVarHelp = $('question_help_IO_' + myVar.id.split(':')[1] + '_toggle');


                  toggleVariableHelpText(myVarHelp);


      }


  }


}


View solution in original post

11 REPLIES 11

Chuck Tomasi
Tera Patron

Hi Kevin,



Can you share your onLoad information? I've never seen this done. Theoretically, if you can open it in onLoad, you can open it onChange.



Just for clarification,we're talking about catalog client script working on a variable, right? Or is this a client script working on a field (which doesn't have a More Information bit.)



Thanks.



Creating a Catalog Client Script - ServiceNow Wiki


Hi Chuck,



Here it is:



function onLoad() {


var myVar = g_form.getControl('comments_note');


if(myVar) {


  //toggleHelp(myVar.id);


  //replaced code as suggested by snc


var myVarHelp = $('question_help_IO_' + myVar.id.split(':')[1] + '_toggle');


toggleVariableHelpText(myVarHelp);


}


}


kb22
Kilo Contributor

And yes, I want it to open automatically only if the type_of_request is changed to delete.


Your client script would watch the type_of_request variable. The (untested) script would look like this:



function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading || newValue == '') {


          return;


  }


if (newValue == 'delete') {


      var myVar = g_form.getControl('comments_note');


      if(myVar) {


                  var myVarHelp = $('question_help_IO_' + myVar.id.split(':')[1] + '_toggle');


                  toggleVariableHelpText(myVarHelp);


      }


  }


}