- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 09:13 AM
Hello Guys,
I have a UI Action on the change form and I need to display a dialog window with a specific View from a custom table called timeline. I am using GlideModalForm in order to achieve that but the problem is that I need to set the Parent field from timeline to the number from the parent change form. I tried to use the gModalForm.addParm('parent', sysId); but this is not working and the parent stay empty.
Here is the code:
function timelineDialog(){
var sysId;
if (typeof rowSysId == 'undefined')
sysId = gel('sys_uniqueValue').value;
else
sysId = rowSysId;
var gModalForm = new GlideModalForm('Timelines record', 'table_name);
gModalForm.setPreference('sysparm_view', 'view_name');
gModalForm.addParm('parent', sysId);
gModalForm.setCompletionCallback(function(action_verb, sys_id, table, displayValue){
if (action_verb == 'sysverb_update'){
reloadWindow(window);
}
});
gModalForm.render();
}
Any help will be appropriated, thank you in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 06:02 AM
Guys, this is the solution for that issue:
function timelineDialog() {
ScriptLoader.getScripts('/scripts/classes/GlideModalFormSetWidth.js', function() {
var sysID = g_form.getUniqueValue(); // get the sys_id value from the change request
//Create and open the dialog form
var dialog = new GlideModalForm(new GwtMessage().getMessage("Title to be displayed on the popup message"),'table_name');
dialog.setSize("modal-lg",300);
dialog.setPreference('sys_id','-1'); //-1 to get create new record
dialog.setPreference('sysparm_view', 'name_of_the_view'); //Load 'create' view
dialog.setPreference('sysparm_query','parent='+sysID); //copy the change sys_id to the parent field
dialog.setPreference("sysparm_link_less", "true");
dialog.setPreference('sysparm_view_forced', 'true');
dialog.setPreference('sysparm_clear_stack', 'true');
//Fuction called on feedback submit, to add success message and refresh Knowledge Feedback Task related list
dialog.setCompletionCallback(function(action_verb, sys_id, table, displayValue){
location.reload();
var feedTaskNum = '<a href="/u_moj_timeline.do?sys_id='+sys_id+'&sysparm_view=">' + displayValue +'</a>';
g_form.addInfoMessage( new GwtMessage().getMessage("Successfully created Table Record [name of the table]: {0}",feedTaskNum));
});
//Open the dialog
dialog.render();
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 09:31 AM
Hi,
your table name is "u_timeline" but you are sending name as "u_moj_timeline"
can you tell your requirement?
on click of button you want to open dialog window with some table and specific view. what next?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 06:14 AM
Thank you very much for your answer, but the table name was correct the problem was with the code 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 11:37 AM
Hello,
I ran into this as well and I believe all you need to do is, wherever you are setting the Parent field in your script, use "parent.value" rather than just "parent". See below where I am setting the short description to my 'testVal' variable added as a parameter when instantiating the modal form:
function cancelTicket() {
var d = new GlideModalForm('Create New incident', 'incident');
d.setOnloadCallback(populateModal);
d.addParm('testVal', 'test');
d.render();
function populateModal() {
//Access GlideModal g_form
var d_form = window.frames["dialog_frame"].g_form;
d_form.setValue('short_description', testVal.value);
}
}
I hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 06:02 AM
Guys, this is the solution for that issue:
function timelineDialog() {
ScriptLoader.getScripts('/scripts/classes/GlideModalFormSetWidth.js', function() {
var sysID = g_form.getUniqueValue(); // get the sys_id value from the change request
//Create and open the dialog form
var dialog = new GlideModalForm(new GwtMessage().getMessage("Title to be displayed on the popup message"),'table_name');
dialog.setSize("modal-lg",300);
dialog.setPreference('sys_id','-1'); //-1 to get create new record
dialog.setPreference('sysparm_view', 'name_of_the_view'); //Load 'create' view
dialog.setPreference('sysparm_query','parent='+sysID); //copy the change sys_id to the parent field
dialog.setPreference("sysparm_link_less", "true");
dialog.setPreference('sysparm_view_forced', 'true');
dialog.setPreference('sysparm_clear_stack', 'true');
//Fuction called on feedback submit, to add success message and refresh Knowledge Feedback Task related list
dialog.setCompletionCallback(function(action_verb, sys_id, table, displayValue){
location.reload();
var feedTaskNum = '<a href="/u_moj_timeline.do?sys_id='+sys_id+'&sysparm_view=">' + displayValue +'</a>';
g_form.addInfoMessage( new GwtMessage().getMessage("Successfully created Table Record [name of the table]: {0}",feedTaskNum));
});
//Open the dialog
dialog.render();
});
}