gr.insert doesn't work

yundlu316
Kilo Guru

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!

6 REPLIES 6

Brian Dailey1
Kilo Sage

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


tombialkowski
Giga Expert

How I would troubleshoot this:


  1. Comment out the newly added 42 items.
  2. Verify that it's working
  3. Uncomment 1 item.
  4. Verify that it's working.
  5. 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!


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.


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