g_form.save() and g_form.submit() behavior through GlideDialogForm?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 02:00 AM
Hi,
will be possible to clarify how save and submit methods behave?
According to ServiceNow Doc the save() method is the equivilant of save and stay. and submit() is save and return to previous page.
i am experiencing some different behavior when utilized through a GlideDialogForm.
When invoking save() on the dialog the record is save and the dialog is closed.
If i use submit() nothing appears to happen. The records is not saved and the dialog remains open.
Build name: Kingston
Build date: 01-03-2018_0843
Build tag: glide-kingston-10-17-2017__patch1-12-12-2017
var modal = new GlideDialogForm('Create outages', tableName, createOutages);
modal.addParm('sysparm_view', 'Default view');
//Use onload event for dialog to read values from spawning windows.
modal.setLoadCallback(function (iframeDoc)
{
//dialog reference.
var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
//get values from incident to dialog
//skip if g:form undefined. onLoad callback fired on open and close of dialog.
if (dialogFrame.g_form)
{
jslog("###ONLOAD CALLBACK###");
var CisysIds = g_list.getChecked();
jslog("Selected CIs: " + CisysIds.length);
dialogFrame.g_form.setValue("u_impacted_sevice_ids", CisysIds);
dialogFrame.g_form.setValue("u_incident", g_form.getUniqueValue());
jslog(dialogFrame.g_form.getUniqueValue());
//Save record - Reference filters are executed server side.
//input is via current record keyword. Which will only have data when record have been persisted.
//uncomment to try
//dialogFrame.g_form.save();
//dialogFrame.g_form.submit();
}
});
modal.render();
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 06:20 AM
Found a solution.
Instead creating the record as the last step in the sequence i created it first and linked the GlideDialogForm to the sys id of the newly created record.
var CisysIds = g_list.getChecked();
//insert record.
grOutageBulkInsert = new GlideRecord(tableName);
grOutageBulkInsert.initialize();
grOutageBulkInsert.u_impacted_sevice_ids = CisysIds;
grOutageBulkInsert.u_incident = g_form.getUniqueValue();
var OutageBulkSysId = grOutageBulkInsert.insert();
var modal = new GlideDialogForm('Create outages', tableName, createOutages);
//link sys id to dialog.
modal.setPreference('sys_id', OutageBulkSysId);
modal.addParm('sysparm_view', 'Default view');
modal.render();