gr.insert doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 02:55 PM
I'm using a UI Page to build a custom form and am using the following insert script to take what the user submits and puts each field in its corresponding field in the table:
<script>
function Redirect() {
window.location="www.somepage.com";}
</script>
<script>
function submitRequest()
{
var gr = new GlideRecord('u_employee_form');
gr.initialize();
gr.u_item_a = document.getElementById('A').value;
gr.u_item_b = document.getElementById('B').value;
gr.u_item_c = document.getElementById('C').value;
gr.insert();
}
</script>
HTML button: <button id="myButton" onclick = "submitRequest(); Redirect();">Submit</button>
This script seem to work great with just 3 fields to insert, but when I tried to enter 45 different fields, the page stopped working. The submit button no longer redirects, it's as if it loses all functionality or can't handle the code. Am I doing something wrong here?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2016 11:17 PM
Hi David,
Have you tried any logging to see if you're getting an error? You might be mixing server-side calls into your client-side script... I notice you use initialize(), but I think this is only available on server-side GlideRecords.
You might be generating an error that stops you script.
-Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2016 01:14 PM
How I would troubleshoot this:
- Comment out the newly added 42 items.
- Verify that it's working
- Uncomment 1 item.
- Verify that it's working.
- Repeat steps 3 & 4.
The idea here is to narrow down what's causing the problem, and I wouldn't be surprised if it turns out that one of your 43 field names isn't lining up with what's in the table. Hope it helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2016 05:26 PM
Hi Tom and Brian,
I did exactly as you suggested, testing the code line by line and it appears that this code on UI Pages can only handle 15 variables. The moment I add more than 15, the code stops working. I'm currently looking into alternatives to this issue. If you guys think of any please let me know as well.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2016 06:13 PM
Hi David,
That sounds odd. Most probably you had a typo or error on your script.
I'll also recommend you use some best practices like using GlideAjax instead of using a GlideRecord from the client side.
Thanks,
Berny