- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 10:12 AM
With GlideModalForm v3 it is possible to open a form in an overlay content dialog. GlideModalForm is also featuring a onloadCallbackfunction. How can we gain access to the g_form of the record object that has been opened by the GlideModaWindow
Example:
Lets say we have a "Create Problem" button on the Incident Form that opens a GlideModalForm:
var d = new GlideModalForm("Hello World", "problem");
d.setOnloadCallback(someFunction);
d.setSysID(-1);
someFunction(oGlideModal) {
g_form.addInfoMessage("By submitting this Problem you will set the Incident to Pending Incident");
==> This g_form Object is still pointing to the Incident Record. How to point to the g_form Object of the Problem?
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 04:35 PM
It seems like GlideModalForm is rendering a Bootstrap Modal in a frame called "dialog_frame". The access to the g_form object in the rendered Modal is possible via window.frames["dialog_frame"].g_form
For Example if you open a GlideModalForm to create a new problem from an Incident, you can Access the Problem and Incident Values in the onLoadcallback as followed. The only thing that does not seem to work with GlideModal is g_form.addInfoMessage() and g_form.addErrorMessage();
var d = new GlideModalForm("Create Problem", "problem");
d.setOnloadCallback(showInfoOnProblem);
d.setSysID(-1);
d.render();
function showInfoOnProblem(oGlideModal) {
var oModalGForm = window.frames["dialog_frame"].g_form;
alert(g_form.getValue("number")); //Alerts the Incident numer
alert(oModalGForm .getValue("number")); //Alerts the Problem Number
g_form.showFieldMsg("number", "This message is shown on the Incident form under the number field");
oModalGForm.showFieldMsg("number", "This Message is shown on the Create New Problem Modal under the number field");
g_form.showInfoMessage("This message is shown on the Incident form");
oModalGForm.showFieldMsg("number", "Info Messages an Modals do not seem to work");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 04:35 PM
It seems like GlideModalForm is rendering a Bootstrap Modal in a frame called "dialog_frame". The access to the g_form object in the rendered Modal is possible via window.frames["dialog_frame"].g_form
For Example if you open a GlideModalForm to create a new problem from an Incident, you can Access the Problem and Incident Values in the onLoadcallback as followed. The only thing that does not seem to work with GlideModal is g_form.addInfoMessage() and g_form.addErrorMessage();
var d = new GlideModalForm("Create Problem", "problem");
d.setOnloadCallback(showInfoOnProblem);
d.setSysID(-1);
d.render();
function showInfoOnProblem(oGlideModal) {
var oModalGForm = window.frames["dialog_frame"].g_form;
alert(g_form.getValue("number")); //Alerts the Incident numer
alert(oModalGForm .getValue("number")); //Alerts the Problem Number
g_form.showFieldMsg("number", "This message is shown on the Incident form under the number field");
oModalGForm.showFieldMsg("number", "This Message is shown on the Create New Problem Modal under the number field");
g_form.showInfoMessage("This message is shown on the Incident form");
oModalGForm.showFieldMsg("number", "Info Messages an Modals do not seem to work");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2018 03:37 PM
Awesome - thanks for shedding light on this as the documentation is severely lacking. GlideDialog is a very useful utility - not sure why this isn't championed more.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 11:36 AM
Bringing this up again. The correct answer here does not work for me. I am getting the error that the frames object is not defined in the browser console. I figure this should be pretty straight forward and am suprised there isn't more documentation on how to access the form, seeing as you could do it pretty easily with the GlideDialogForm object. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 06:05 AM
Hi Tony,
The solution provided by me is for GlideModalForm. GlideDialogForm is a different class. I would suggest to use GlideModalForm as it is described as re-worked GlideDialog and GlideDialogForm is not documented at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2018 06:47 AM
Hopefully you got this resolved but I managed to populate the Modal by adding sysparm_query...
d.addParm('sysparm_query', 'tasks='+g_form.getUniqueValue()+'^task_table='+g_form.getTableName()); // populate fields