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

Your link to an example does not work but figured out you where trying to point me to the "Copy Incident" UI Action.  I tried the g_modal.showFields but I need a date field and could not find any docs and no examples of showing a date field so that was/is out since type of date, date_time, datetime all did not work.

I have looked at the link you posted about showing a component, but which one do I pick to show a form for a custom table?  I tried some of the ones that have form in the name and could not get any to work properly.  None of the ones listed have any docs so there is no way get them to work easily and I do not have the dev time in this project to spend a week developing a web component just to show a form like you can on the platform UI with a simple Dialog window.

Right now I have the g_modal.showFrame sort of working but it does not expand to show the whole form, it shows about two rows of single line text fields at a time which my users found more frustrating then having to close an extra tab when they were done creating a record.

So still looking for something that can show a form view of a table that does not create a new tab like you can using a dialog window on the platform UI.

 

 

Jeremy Duncan
ServiceNow Employee
ServiceNow Employee

@Drew - I'm betting you were unable to even try the New Component via Modal option I sent because it appears you have to have 'maint' role to even create a new one 🙂 unless of course you got around it with the below method, if so scratch my suggestion. I've reported this issue internally. I'd suggest the following:

1. elevating to 'security_admin'

2. Navigate to the ACL for that table (please don't click this link, it won't work. Edit then go): https://YOURINSTANCE.service-now.com/nav_to.do?uri=%2Fsys_security_acl.do%3Fsys_id%3De5269a850f13330...

3. Update then try down the path of doing this method. 

 

Interested in hearing your results.

 

Jeremy Duncan

Yes I had to update the ACL's on the table to even consider trying it.

Just to be complete I did get a component to load in a dialog but I do not have time in the project to build a custom one that just shows the form properly and the existing components that have form in the name I could not get any of them to work properly as stated above.

Winston
Tera Guru

Any luck on this, Drew?