- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 06:09 AM
I'm attempting to add a "Pop UP" window that will generate a prepopulated Outage record we a field changes value.
So i have field u_maintenance_type you can select Major or Minor.
On the Onchange client script i have
if(newValue=='major'){
//g_form.save();
openNewWin();
}
This is calling my UI Action
function openNewWin(){
var tyP = g_form.getValue('u_maintenance_type');
if(tyP=='major'){
tyP = 'planned';
} else {
tyP = '';
}
var bDate = g_form.getValue('start_date');
var eDate = g_form.getValue('end_date');
var mCI = g_form.getValue("cmdb_ci");
var sysID = g_form.getUniqueValue(); // get the sys_id value from the change request
//Create and open the dialog form
var dialog = new GlideModalForm('Outage Task','cmdb_ci_outage');//was GlideModalForm
dialog.setSize("modal-lg",300);
dialog.setPreference('sys_id','-1'); //-1 to get create new record
var q = 'short_description='+g_form.getValue("short_description") + "^cmdb_ci="+ mCI +"^begin=" + bDate +"^end=" + eDate + "^type=" + tyP +'^task_number='+sysID;
dialog.setPreference('sysparm_query',q); //copy the change sys_id to the parent field
//Fuction called on feedback submit, to add success message and refresh Knowledge Feedback Task related list
dialog.setCompletionCallback(handleAdapterCreatedOrUpdated);
dialog.render();
}
function handleAdapterCreatedOrUpdated(test,sys_id,table,displayValue){
location.reload();
}
The issue i'm having is that when you click the Save button on the pop-up, you get the following message.
Reload - will remove the Onchange value in the field and reload the form. I get the new outage, but Maintenance Type reverts to old value and rated lists show the new outage.
Cancel - closes the pop-up but the outage doesn't show in related lists until you save the form.
I've looked at this way to many times and I know i'm missing the obvious.
How can i get the the form to save prior to the popup opening?
Or save it when you "Save" the Outage record.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 08:18 AM - edited 01-27-2025 08:20 AM
I figured it out.
I added the save function to my Create outage UI action.
It saved and reloaded the Change form as expected.
Reload was important to show Outage in the related lists.
Updated last lines as follows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 07:47 AM
If you don't want the browser window to be reloaded, why are you writing code to reload it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 08:18 AM - edited 01-27-2025 08:20 AM
I figured it out.
I added the save function to my Create outage UI action.
It saved and reloaded the Change form as expected.
Reload was important to show Outage in the related lists.
Updated last lines as follows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 08:19 PM
There is an API to reload just a related list, you know.
In UI 16 there is a global object named GlideLists2 that has GlideList2 objects attached to it as properties - one for each related list on the current form.
So in order to refresh the list of child incidents (for instance) on an incident form, without all the totally unnecessary reloads, one might just write:
GlideLists2['incident.incident.parent_incident'].refresh();
Simple as that.