- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 06:40 AM
This is a part of this question:
So I have a custom form in a widget (Service Portal page).
By submitting I'd like to store all the data to my table.
Firebug says that gr.insert() is not defined:
$('#submit').click(function(){
var gr1 = new GlideRecord('x_11234_notes_customers');
gr1.initialize();
gr1.name = 'first to do item';
gr1.list_of_services = 'learn about GlideRecord';
gr1.insert();
});
Where am I wrong here?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 08:54 AM
Hi Ivan,
What it's doing now is running your insert when the page loads. When you run the update the data object gets passed back to the server as the input object, so try this in your server side script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if (input) {
var gr = new GlideRecord('x_1111_customers');
gr.initialize();
gr.name = input.name;
gr.list_of_services = input.list_of_services;
gr.insert();
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 09:09 AM
Glad it worked. Also notice that the if (input) check makes sure the code doesn't run when the widget loads and creates a blank record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 09:14 AM
for sure. understood. thanks.
Brad, quick question here:
It was an empty form for creating a new customer.
Now I need to open this form for existing customer by clicking "edit" button from another SP page (from another widget).
How can I open this page from another one? In other words, I need to pass "customer" object from another widget to the current widget.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 09:16 AM
You would link to it and pass a url parameter, then your client and server side code would grab the sysid from the url parameter and populate the data object onload in that way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 09:20 AM
thanks.
will try.