<g:ui_form> processing scripts

Stewe Lundin
Mega Guru

Hi!

Setup:
I have a UI Action from the Incident form, a button.

The button opens a dialog that loads data from the Time Card table, showing reported time on the incident connected to the employee. 

The dialog has a number of fields that the user can change and some of the are pre populated with data from the incident and also data retrieved from other tables.

The issue:
When saving the form to the Time card table, pressing the submit button in the form, the page reloads, and instead of closing the dialog and returning to the incident form, the dialog "takes over" and the incdent form is "lost". 

find_real_file.png

On pressing submit 
find_real_file.png

I have tried to trigger the processing script in a few ways and then only way I can get it to work is with a simple Submit Button 

<div class="right"><button>Submit</button></div>

 This will not even trigger the Processing script.

 <g:dialog_buttons_ok_cancel ok="return validateDialog()" ok_type="button" cancel_type="button" />

the validateDialog() in client script , closes the dialog and returns true, and then nothing happens

function validateDialog() {
	
	GlideDialogWindow.get().destroy(); //Close the dialog window
	
	return true;
}




What I want to achieve, is to close the dialog, save the data and return to the incident form. 
I can close the dialog box,via client script, but I cant trigger the  processing scrip or I can trigger the process script but not close the dialog and return to the incident form. 

 

 

1 ACCEPTED SOLUTION

Stewe Lundin
Mega Guru

This fixed it. 

Added to the Processing script;

var urlOnStack = GlideSession.get().getStack().bottom();
	response.sendRedirect(urlOnStack);

 

View solution in original post

9 REPLIES 9

Dante Ditan
Kilo Sage

Please try to add a client script in your ui page and bind it to onclick. Add your destroy with return false;

Stewe Lundin
Mega Guru

I tried that!

Still not working. 

It saved the data but I dint destroy the form, it reloads it. 

I guess that I have to redirect the page after the processing script i finished. 

Some how. 

HTML:(in a shorter version)

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<g:ui_form>
<input type="hidden" name="test" id="test" >

		<div class="right">
			<button onclick="validate()">Submit</button>
		</div>
		</g:ui_form>
</j:jelly>


Client Script: (full)

function validate(){

	GlideDialogWindow.get().destroy();
	return false;
}



Processing script:(Full, but do not match the HTML from this example)

	var tc = new ax_time_card();
	var time_card = {
		sys_id:request.getParameter('time_card_sys_id'),
		state:request.getParameter('state'),
		u_timecode:request.getParameter('u_timecode'),
		u_workorder:request.getParameter('u_workorder'),
		u_project:request.getParameter('u_project'),
		u_activity:request.getParameter('u_activity'),
		monday:request.getParameter('monday'),
		tuseday:request.getParameter('tuseday'),
		wednesday:request.getParameter('wednesday'),
		thursday:request.getParameter('thursday'),
		friday:request.getParameter('friday'),
		saturday:request.getParameter('saturday'),
		sunday:request.getParameter('sunday')
	};
	gs.info('Saved:' + tc.save_time_card(time_card));
	

I'm not a fan using g:ui_form in terms of using it in glidedialogwindow. What I did is remove the ui form and do it in a client script using glideajax. From there you can eliminate the page from redirecting and you may use the destroy to close it.

 

Thank you

Dante

Stewe Lundin
Mega Guru

This fixed it. 

Added to the Processing script;

var urlOnStack = GlideSession.get().getStack().bottom();
	response.sendRedirect(urlOnStack);

 

This gem has saved me so much time. Thanks!