Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to access classes in scoped applications?

joseeduardo
Giga Expert

Hi guys I am trying to access to GlideRecordUtil from a business rule within an application(scoped application that I am developing), the problem is that I get this message in the form where I am applying the business rule:

find_real_file.png

I really need to use GlideRecordUtil, is there any way to achieve this? just to give you a little bit of background I am trying to record all fields that changes in the form from the server side!, any idea how to fix the GlideRecordUtil issue or maybe another alternative?

************Ignore that the application picker says Global, it said global just because for a moment I changed the application picker to global to make some testings using the same script in another Business rule in global scope and by the way IT WORKED!!!!********* so I dont think it is a script issue.***********

5 REPLIES 5

Rahul Jain11
Kilo Guru

Hi,



To make a call for the global scripts includes from a scoped application, you need to use global name space before initiating them. so you have initiate like:



var gr = new global.GlideRecordUtil();



and make sure that GlideRecordUtil is accessible from all applications.


I made this change:


find_real_file.png



But now I get this output instead:



find_real_file.png


joseeduardo
Giga Expert

Hello Rahuljain! if the script goes like this where should I place the "global word",




if (typeof GlideScriptRecordUtil != 'undefined'){


      var gru = GlideScriptRecordUtil.get(current);


  }


  else{


      var gru = Packages.com.glide.script.GlideRecordUtil.get(current);


  }


  var changedFields = gru.getChangedFields(); //Get changed fields with friendly names


  var changedValues = gru.getChanges(); //Get changed field values


  //Convert to JavaScript Arrays


  gs.include('j2js');


  changedFields = j2js(changedFields);


  changedValues = j2js(changedValues);


Hi,



Did you get a solution to this?