g_modal.showFrame in Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 01:02 AM
Hi all,
I'm working on Agent Workspace and I have a client script which open a UI Page with g_modal.showFrame() method.
My issue is that in this UI Page (in client side) I set value of a field using g_form.setValue("field_name", value), but on Agent Workspace it doesn't work because I get the error "g_form is not defined".
So, there is a way to access g_form to set field value based on UI Page content? I have to do this client side to ensure the process works properly.
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 01:11 AM
Hi,
Can you show the script and explain which page you are opening from this frame?
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 01:24 AM
Hi,
this is the client script in which i open the UI Page:
if (check == "true") {
var url = "PopupIntegrazione.do?categoria=" + g_form.getValue('u_categoria') + "&sottocategoria=" + g_form.getValue('u_sottocategoria');
g_modal.showFrame({title: "Indicare il tipo di segnalazione", url: url, size: "sm"});
}
In UI Page Client script I have some instructions like this:
g_form.setValue('u_appoggio_integrazioni', document.getElementById( 'appoggio' ).value );
(the document.getElementById("appoggio").value takes the value of an input field in defined in UI Page HTML.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2020 05:51 AM
Below is an OOTB code use in Major Incident management - UI action "Propose Major Incident". Use it as per your needs.
//Script for UI Action
function promptForProposalReason() {
//checking for work_notes visibility
if(!g_form.getControl('work_notes')) {
getMessage('Cannot propose major incident as "Worknotes" is not visible', function(msg) {
g_form.addErrorMessage(msg);
});
return false;
}
var dialog = new GlideModal('sn_major_inc_mgmt_mim_propose', false, 651, 250);
getMessage('Propose Major Incident', function(msg) {
dialog.setTitle(msg);
});
ScriptLoader.getScripts('/scripts/incident/glide_modal_accessibility.js', function() {
dialog.template = glideModalTemplate;
dialog.on('bodyrendered', function(event) {
glideModalKeyDownHandler(event, dialog.getID());
});
dialog.setPreference('WORK_NOTES', g_form.getValue('work_notes'));
dialog.setPreference('BUSINESS_IMPACT', g_form.getValue('business_impact'));
dialog.setPreference("focusTrap", true);
dialog.render();
});
//This dialog will be destroyed in UI Page 'sn_major_inc_mgmt_mim_propose'
}
if(typeof window == 'undefined')
proposeMICOnConfirmation();
//Server-side code
function proposeMICOnConfirmation() {
current.major_incident_state = new sn_major_inc_mgmt.MajorIncidentTriggerRules().MAJOR_INCIDENT_STATE.PROPOSED;
current.update();
gs.addInfoMessage(gs.getMessage('{0} has been proposed as a major incident candidate', current.getDisplayValue()));
action.setRedirectURL(current);
}
//Workspace Client Script
function onClick(g_form) {
function proposeMIC(data) {
var workNotes = data.msg + "\n" + data.workNotes;
var notes = g_form.getValue('work_notes') + ' ' + workNotes;
var bi = g_form.getValue('business_impact') + ' ' + data.businessImpact;
g_form.setValue('work_notes', notes.trim());
g_form.setValue('business_impact', bi.trim());
g_form.submit('sysverb_mim_propose');
}
function openPopup() {
if(!g_form.getControl('work_notes')) {
getMessage('Cannot propose major incident as "Worknotes" is not visible', function(msg) {
g_form.addErrorMessage(msg);
});
return false;
}
var url = "/sn_major_inc_mgmt_mim_propose.do?sysparm_stack=no&sysparm_workspace=" + true;
g_modal.showFrame({
title: getMessage("Propose Major Incident"),
url: url,
size: 'lg',
autoCloseOn: 'URL_CHANGED',
callback: function (ret, data) {
if (ret)
proposeMIC(data);
}
});
}
openPopup();
}
PS:- Mark helpful or correct based on the impact of the answer to your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:26 AM
Is this working?
UI page is not getting called back when clicked on "Ok".
Could you please help on the UI page script which need to call back the function with ret and data variables.
Thank you