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

Hi Berny,



I've checked my syntax countless times and I don't believe it to be the issue.   I've added all 40 variables back into the code and tried filling out each variable and pressing submit, one at a time.   Once I filled out a certain number of variables, the submit button works.   I'm super confused right now...



Also I'm not familiar with GlideAjax, is the syntax for that the same as GlideRecord?


Hi David,



Here goes some links so that you can accomplish what you need using a GlideAjax or at a minimum an asynchronous GlideRecord.



GlideAjax - ServiceNow Wiki


Examples of asynchronous GlideAjax



In case you still want to go through the GlideRecord route, i will then at least propose you do it with an asynchronous call


Can you call a script include from a client script - without GlideAjax?



Thanks,


Berny