Add GlideRecord UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2016 06:08 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2016 07:06 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2016 07:09 AM
Thanks. Based on the description, I don't think this needs to be a combination of client and server side. Start simple.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2016 07:07 AM