GlideDialogWindow, GlideModalForm or g_modal.showFrame not working...?

DrewW
Mega Sage
Mega Sage

Ok, I must have a case of the stupids and am missing something obvious.  I have a custom table and on Workspace I need to create a button to open a dialog box and simply show the new record form for the custom table. I have tried using GlideDialogWindow, GlideModalForm and g_modal.showFrame. Each time in the browser console I see "Action succeeded" and there is no error, but the dialog does not open. I have to be missing something.

Code I have tried.

//First try
var dialog = new GlideDialogWindow("x_mahe2_cgna_member");
dialog.setTitle("New Member");
dialog.setPreference("sysparm_sys_id", "-1");
dialog.render();

//Second Try
var dialog = new GlideModalForm("New Member", "x_mahe2_cgna_member", populateMember);
dialog.setTitle("New Member");
dialog.setSysID(-1);
dialog.addParm("sysparm_view", "default");
dialog.addParm("sysparm_form_only", "true");
dialog.render();

//Third Try
var url = "/x_mahe2_cgna_member.do?sysparm_view=workspace&sys_id=-1&sysparm_form_only=true&sysparm_workspace=true";
g_modal.showFrame({
	title: "New Member",
	url: url,
	size: 'lg'
});
1 ACCEPTED SOLUTION

So the only way I found to do this was using g_modal.showFrame but it has its own issues.  I have not had a chance to test it in Paris because we have not upgraded yet.  My code is below to show a specific form and it has to be a workspace script.  Right now the "lg" size is not very large in my opinion and you can only see about two rows of fields which sucks but since there was no documentation that I could find at the time of writing.

function onClick(g_form) {
	var url = "/TABLE_NAME.do?sysparm_view=workspace&sys_id=-1&sysparm_form_only=true&sysparm_titleless=true&sysparm_link_less=true&sysparm_workspace=true";
	var x = g_modal.showFrame({
		title: "New Member",
		url: url,
		size: 'lg'
	});
	
}

View solution in original post

19 REPLIES 19

So the only way I found to do this was using g_modal.showFrame but it has its own issues.  I have not had a chance to test it in Paris because we have not upgraded yet.  My code is below to show a specific form and it has to be a workspace script.  Right now the "lg" size is not very large in my opinion and you can only see about two rows of fields which sucks but since there was no documentation that I could find at the time of writing.

function onClick(g_form) {
	var url = "/TABLE_NAME.do?sysparm_view=workspace&sys_id=-1&sysparm_form_only=true&sysparm_titleless=true&sysparm_link_less=true&sysparm_workspace=true";
	var x = g_modal.showFrame({
		title: "New Member",
		url: url,
		size: 'lg'
	});
	
}

Hello,

Just want to add that adding "height" to modal object shows a few more lines in height, but far from a normal form size. Below will show about 6 or 8 fields high (which for us means agents need to scroll to find Submit).

var x = g_modal.showFrame({
    title: "New Member",
    url: url,
    size: "lg",
    height: "34rem" // height: 500 also works
});

Thanks for the info. This helped me. I am using size: 'fw'; instead of xl which opens the modal in full windows (?). I think height is another way to play with the size of the modal.

 

  • title: the title of the modal dialog window
  • size: sm, lg, xl, and fw seems to work, but sm, lg, xl doesn't seems to be a lot of differences
  • height: a height (in pixels) for the modal (?)

Do you know if params (parameters to pass in to the inner component) works with g_modal.showFrame?

mak1A4
Tera Guru

So for anyone who has the issue that g_modal doesn't open, you have to set the client flag to true on the ui action for it to work. That took me a while to figure that out ^^

@martin. You saved me with this comment.  You should post a comment on my thread to get credit for your effort.  https://community.servicenow.com/community?id=community_question&sys_id=57908ec0db650110a538826305961952