- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:11 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:50 AM
Also make sure you use the name of field not label.
Thanks,
Shamma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:24 AM
Hi Maxime,
Al your coding it sinf eit just that insert functon is missing.
database.insert();
USe this function and then it will start working.
Regards,
Shamma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:30 AM
Hi,
You mean as Aakash said?
var database = new GlideRecord('u_test');
database.initialize();
database.setValue('field_one','hello');
database.setValue('field_two',4);
database.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:33 AM
Hi Maxime,
Yes because only that statement is missing.
Also, please let me know that what is the data type of your field one and field two?
Regards,
Shamma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:39 AM
Re: It stills add a ro without any value in it.
Regards,
Maxime
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:39 AM
'field_one' is string 'field_two' is integer.