Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to pass value from current page to DialogForm ?

kambleneeta20
Giga Expert

Hi ,

I have used following code to open the dialog form, now how can I pass the current from value to Dialog form ? Please suggest? Thanks in advance.

UI Action code -> 

function publish() {
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
var gDialog = new GlideDialogForm('MM ITAM', 'pc_software_cat_item',dothis); //Provide dialog title and table name
gDialog.render();
}
//this is my callback function. All I am doing is taking the sys_id and using the setValue to place it in the caller_id field.
function dothis(action, sys_id, table, displayValue) {
g_form.setValue('product_catalog_item', sys_id);
}

find_real_file.png

 

1 ACCEPTED SOLUTION

ScienceSoft
Tera Guru

hi, kambleneeta20@gmail.com

if need to pass values into the dialog from original form, in this case need to set a callback function to pass and set those values into dialog like this:

function publish() {
	var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
	var gDialog = new GlideDialogForm('MM ITAM', 'pc_software_cat_item',dothis); //Provide dialog title and table name
	
	gDialog.setLoadCallback(function(iframeDoc) {
		// To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
		var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
		dialogFrame.g_form.setValue('name', g_form.getValue('your_fieldName'));
	});
	gDialog.render();
}

 

View solution in original post

2 REPLIES 2

ScienceSoft
Tera Guru

hi, kambleneeta20@gmail.com

if need to pass values into the dialog from original form, in this case need to set a callback function to pass and set those values into dialog like this:

function publish() {
	var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
	var gDialog = new GlideDialogForm('MM ITAM', 'pc_software_cat_item',dothis); //Provide dialog title and table name
	
	gDialog.setLoadCallback(function(iframeDoc) {
		// To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
		var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
		dialogFrame.g_form.setValue('name', g_form.getValue('your_fieldName'));
	});
	gDialog.render();
}

 

Thanks a lot. It worked.