Fuji client scripts: document object is null

aklimenko
Mega Expert

Hi

We use document.getElementById() or gel() in client scripts to get controls. In some places we cannot replace it with g_form. For example, I need to get a catalog item sys_id in variable set client script so the only way I could do that was document.getElementById("sysparm_id").value

What I found out is that for any client script document object is null:

[Error] TypeError: null is not an object (evaluating 'document.getElementById')

Any ideas?

42 REPLIES 42

BobbyNow
ServiceNow Employee
ServiceNow Employee

The "i" icon will hide based on the state of the system property "glide.ui.reference.readonly.clickthrough".


Customizing the Reference Icon - ServiceNow Wiki


Bobby, just wanted to let you know that I was able to set that icon as not visible by using the following statement:



g_form.getReference('access_description', function(ref) {


g_form.removeDecoration('access_description', 'icon-info');


});



I put that code in a Client Script on change of the access_description variable.


Thank you very much for your time!


BobbyNow
ServiceNow Employee
ServiceNow Employee

That's great. Glad it worked out.


it did not worked for me , is your application is a scoped application ?


Hey srnewbie, we used the global application. The complete client script used was:



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



  if(newValue != ''){



  //-- Hide the Access Description Hover Icon


  if(access_description != ''){


  g_form.getReference('access_description', function(ref) {


  g_form.removeDecoration('access_description', 'icon-info');


  });


  }



  }



Being "Access_description" the variable name of the onChange client script. Can you share what you are using? Have you upgraded to Fuji?