Client-side equivalent of current.update?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 02:54 AM
We created our own application and wanted to create something similar to the UI Action "Create Problem" (or change, etc). After the button is pressed, a new record should be created and both should be linked to each other through the reference field. We would like to have these buttons available on both sides and on new records as well. In the one direction the code is pretty straightforward:
current.update(); //Checks for mandatory fields. Stops when not filled in, continues when filled in.
var obj = new MyObject();
obj.createOtherRecord(current);
In the other direction, we need additional information. Here I'm stuck.
I created a UI Page that asks for the information and finally calls the above code with the additional parameter
var obj = new MyObject();
obj.createOtherRecord(current, parameter);
Putting the update right before that is not good. Current isn't available and it's way too late to check for mandatory fields then. So we want to put it as the first line of code in the UI Action, before the UI Page gets called and if an error occurs, the UI Page should not be opened. But as this is a Client-Side UI Action, the only thing I know of is using "g_form.submit()", but that doesn't seem to show pretty alerts about empty mandatory fields. Using "gsftSubmit" works partially.
gsftSubmit(null, g_form.getFormElement(), '');
if(typeof window != 'undefined')
return;
/* Script for opening the UI Page */
The above code stops correctly when mandatory fields are not filled in and warns me about it. When all fields are filled in it somehow complains that "Changes have been made to the record and will not be saved", which is not what I wanted to see...
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2016 12:15 PM
Run this, client side, to save the record:
gsftSubmit(document.getElementById('sysverb_update_and_stay'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2016 07:13 AM
That doesn't work, because it refreshes the page and thus prevents the dialog from opening, I want opened after the update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2016 07:39 AM
g_form.save() ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2016 07:51 AM
That seems what I need, but the problem is, that it is not working well together with the popup. When it complains about mandatory fields, it still shows the popup and when it does not complain, it still refreshes the form and the popup does not show...
g_form.save();
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
var dd = new dialogClass("dialog");
dd.render();