script insert row in table

lamson_
Giga Contributor

Hello Ladies and Gentlmen,

I have a table call 'u_test' and there are the fields 'field_one' and 'field_two',

i would like to write a script that will create a row in this table with 'field_one' and 'field_two' fill.

My current attempt was with:

var database = new GlideRecord('u_test');

database.initialize();

database.field_one='hello';

database.field_two=4;

database.insertWithReferences();

But it only create a record without any value in the 'field_one' and 'field_two'.

Maxime NGUYEN.

----------------------------

Re all: Thanks for all your answer,

Sorry for all your trouble, i'm embarassed, actually there isn't any error in the script itself, it was just me who had put caps without noticed it.

Message was edited by: Maxime NGUYEN

1 ACCEPTED SOLUTION

Also make sure you use the name of field not label.



Thanks,


Shamma


Regards,Shamma Negi

View solution in original post

18 REPLIES 18

USe this:



var gr = new GlideRecord('u_test');


gr.initialize();


gr.field_one= 'Hello';


gr.field-two= 4;


gr.insert();


Regards,Shamma Negi

Also make sure you use the name of field not label.



Thanks,


Shamma


Regards,Shamma Negi

Hi you are right, i just noticed just before you said it that they were some caps thanks a lot.



Regards,



Maxime.


Please mark my answer as correct if it helped you and solved the issue.



MArk it as Correct solution.



Regards,


Shamma


Regards,Shamma Negi

gopi2203
Tera Expert

Hi Maxime,



Can you please mention the datatype of those fields?