How to replace GlideScriptRecordUtil in Scoped applications ?

Siva Prasad Up1
Tera Contributor

We are developing a custom scoped application for PPM .

Requirement is to update a record feed of a project , when a new status update(using Status Updates -Related list ) record is created.

I have created the Table notification for the same and it is throwing me the following error when a new status update is created.

GlideScriptRecordUtil is not allowed in scoped applications

I did check and came to know business rule created by Table notification is causing this , Business rule script contains

function onBefore(current, previous) {

    //This function will be automatically called when this rule is processed.

var gru =   new GlideScriptRecordUtil.get(current)

var fieldsChanged = gru.getChangedFieldNames();

gs.eventQueue('live_feed.update', current, fieldsChanged.toString(), current.sys_mod_count);

 

}

Is there any replacement for this GlideScriptRecordUtil class in Scoped apps?

12 REPLIES 12

fschuster
ServiceNow Employee
ServiceNow Employee

No update, other than the fact that the API is not supported anymore. I can't really speak about future plans, but right now it does not seem that there are plans to bring that API back.



In terms of the "changed fields" part of the API, you should be able to implement a fairly simple workaround using getElements() and changes() yourself.





Thanks , do you have any examples. I searched online could not find anything relevant.



Thanks in advance.


Try this:



function getChangedFieldNames(gr) {



  var result = [];



  var elements = gr.getElements();


  var size = elements.size();




  for (var i = 0; i < size; i++) {


      var ge = elements.get(i);


      if (ge.changes()) {


          result.push(ge.getName());


      }


  }



  return result;


}


christianmehring



Thanks for posting this, I was finally able to revisit and with slight changes i was able get this working.



function getChangedFieldNames(gr) {



var result = [];


var elements = gr.getElements();


var size = elements.length;


for (var i = 0; i < size; i++) {


var ge = elements[i];


if (ge.changes()) {


result.push(ge.getName());


}


}



return result;


}


Another work around is to create a new Global script include that is available to all scopes.   Create a function that accepts the current record, executes the API call mentioned above, and then returns the list of changed fields.