Add GlideRecord UI Action

kirsvandenbergh
Kilo Explorer

Hi all,

I'm trying to add a record to a scoped application when someone clicks on a custom form button. I have used a UI action for this.

The UI action does not save the GlideRecord and when I debug I get following error: "Uncaught TypeError: GlideRecord is not a constructor".

Here's the code I'm using:

function test() {

  alert("dfkdf");

var sur = new GlideRecord("x_mytable");

sur.initialize();

sur.state = 2;

var successful = sur.insert();

if (successful.isNewRecord()){

alert('inserted');

}

else {

alert('not_inserted');

}

action.setRedirectURL("www.blabla.be");

}

The aim is to save the record and subsequently redirect the user to the newly created record form to add some more detail.

Best regards,

Kris

7 REPLIES 7

If you want both client side and server side code in a single UI action, go thru this link


Client & Server Code in One UI Action - ServiceNow Guru


Thanks. Based on the description, I don't think this needs to be a combination of client and server side. Start simple.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

HI Kris,



The below article should be helpful.


Client & Server Code in One UI Action - ServiceNow Guru