Show second UI page from first one

Vaibhav39
Tera Expert

Hello,

My requirement is to show second UI page from first and that too in same window / frame.

There are two UI pages already created (say page1 & page2).

On click of UI action, if there are records in related list, show page1 & then page2 else show only page2. See below code.

Page1 HTML:

<g:ui_form>
	<input type="hidden" id="cancelled" name="cancelled" value="false"/>
	<input type="hidden" name="task_id" id="task_id" value="${RP.getWindowProperties().get('sysId')}"/>
	<g:evaluate var="jvar_URL" object="true">
        <!-- Code will check records and put all sys_ids in an array and return an URL -->
		url;
	</g:evaluate>
	<table>
		<tr id="dialog_buttons">
			<td colspan="2" align="left">
				<g:dialog_buttons_ok_cancel ok="return onSubmit();" cancel="return onCancel();" />
			</td>
		</tr>
		<br/><br/>
	</table>
	<table>
		<tr>
			<td><iframe src="${jvar_URL}" scrolling="yes" width="900" height="400"/></td>
		</tr>
	</table>
</g:ui_form>

If I wrote the <iframe> first & then dialog_buttons_ok_cancel then those buttons are not displaying.

Page1 Client script:

function onSubmit() {
	var taskId = gel('task_id').value;
	alert("task id="+taskId);
	GlideDialogWindow.get().destroy();
}

function onCancel() {
    var cancel = gel('cancelled');
    cancel.value = "true";
    GlideDialogWindow.get().destroy();
    return false;
}

Page1 Processing script:

if ('false' == cancelled) {
	response.sendRedirect("ui_page.do?sys_id=<SYS_ID_OF_PAGE2>");
}

 

The issue I'm facing is for second page. Page2 is not getting displayed in same UI page window/frame.
Also, if I click on "Cancel" button then it is redirecting to new record instead of same record.

Please help me to solve this issue.

Thanks in advance.

1 ACCEPTED SOLUTION

-O-
Kilo Patron
Kilo Patron

So here's a skeleton of how this could be done:

A client UI Action where field Onclick = u_onClick():

var u_onNextDlg;
var u_onCloseDlg;

function u_onClick () {
	var IS_READ_WRITE = false,
		dialog_1 = new GlideModal('u_ui_page_1', IS_READ_WRITE, 1024);

	dialog_1.setTitle('Title 1');

	dialog_1.render();

	u_onNextDlg = function (dialog_1) {
		return function (param) {
			dialog_1.destroy();

			var dialog_2 = new GlideModal('u_ui_page_2', IS_READ_WRITE, 1024);

			dialog_2.setTitle('Title 1');
			dialog_2.setPreference('sysparm_id', param);

			dialog_2.render();

			u_onCloseDlg = function (dialog_2) {
				return function () {
					dialog_2.destroy();
				};
			}(dialog_2);
		};
	}(dialog_1);
}

Make sure the UI Action is NOT marked as "Isolate script".

Next, the 1st UI Page:

<?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>

		<article class="modal-body">
			<div class="form-horizontal">
				<span class="section">
					<div class="section-content" glide="true">
						<p>Content 1...</p>
					</div>
				</span>
			</div>
		</article>

		<footer class="modal-footer">
			<g:dialog_buttons_ok_cancel cancel_type="button" ok_id="u_ui_page_1_ok" ok="u_onNextDlg('an id')" ok_type="button"/>
		</footer>
	</g:ui_form>
</j:jelly>

Finally the 2nd UI Page:

<?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>

		<article class="modal-body">
			<div class="form-horizontal">
				<span class="section">
					<div class="section-content" glide="true">
						<p>sysparm_id: $[ sysparm_id; ]</p>
						<p>Content 2...</p>
					</div>
				</span>
			</div>
		</article>

		<footer class="modal-footer">
			<g:dialog_buttons_ok_cancel cancel_type="button" ok_id="u_ui_page_2_ok" ok="u_onCloseDlg()" ok_type="button"/>
		</footer>
	</g:ui_form>
</j:jelly>

Of course this is just for demonstration, a lot of things is hard-coded, but when one clicks the UI Action, the 1st UI Page is shown, when that dialog is dismissed pressing the OK button, the 1st UI Page is unloaded and the 2nd UI Page is shown, receiving parameters that might have been passed to it by the 1st UI Page's OK routine. Hard-coded, of course.

Hope this helps.

Just an idea: I don't know why

GlideDialogWindow.get

is used or suggested, as far as I can tell, that is not a thing, method get does not exist on object GlideDialogWindow.

View solution in original post

38 REPLIES 38

I've send you the google meet link on your mail. Please join.

Thank you !!

Vaibhav39
Tera Expert

Hello @Kieran Anson,

Please help me in this scenario.

-O-
Kilo Patron
Kilo Patron

So here's a skeleton of how this could be done:

A client UI Action where field Onclick = u_onClick():

var u_onNextDlg;
var u_onCloseDlg;

function u_onClick () {
	var IS_READ_WRITE = false,
		dialog_1 = new GlideModal('u_ui_page_1', IS_READ_WRITE, 1024);

	dialog_1.setTitle('Title 1');

	dialog_1.render();

	u_onNextDlg = function (dialog_1) {
		return function (param) {
			dialog_1.destroy();

			var dialog_2 = new GlideModal('u_ui_page_2', IS_READ_WRITE, 1024);

			dialog_2.setTitle('Title 1');
			dialog_2.setPreference('sysparm_id', param);

			dialog_2.render();

			u_onCloseDlg = function (dialog_2) {
				return function () {
					dialog_2.destroy();
				};
			}(dialog_2);
		};
	}(dialog_1);
}

Make sure the UI Action is NOT marked as "Isolate script".

Next, the 1st UI Page:

<?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>

		<article class="modal-body">
			<div class="form-horizontal">
				<span class="section">
					<div class="section-content" glide="true">
						<p>Content 1...</p>
					</div>
				</span>
			</div>
		</article>

		<footer class="modal-footer">
			<g:dialog_buttons_ok_cancel cancel_type="button" ok_id="u_ui_page_1_ok" ok="u_onNextDlg('an id')" ok_type="button"/>
		</footer>
	</g:ui_form>
</j:jelly>

Finally the 2nd UI Page:

<?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>

		<article class="modal-body">
			<div class="form-horizontal">
				<span class="section">
					<div class="section-content" glide="true">
						<p>sysparm_id: $[ sysparm_id; ]</p>
						<p>Content 2...</p>
					</div>
				</span>
			</div>
		</article>

		<footer class="modal-footer">
			<g:dialog_buttons_ok_cancel cancel_type="button" ok_id="u_ui_page_2_ok" ok="u_onCloseDlg()" ok_type="button"/>
		</footer>
	</g:ui_form>
</j:jelly>

Of course this is just for demonstration, a lot of things is hard-coded, but when one clicks the UI Action, the 1st UI Page is shown, when that dialog is dismissed pressing the OK button, the 1st UI Page is unloaded and the 2nd UI Page is shown, receiving parameters that might have been passed to it by the 1st UI Page's OK routine. Hard-coded, of course.

Hope this helps.

Just an idea: I don't know why

GlideDialogWindow.get

is used or suggested, as far as I can tell, that is not a thing, method get does not exist on object GlideDialogWindow.

Thanks Janos! I really appreciate your efforts.

Actually, there are two pages already created by other person. I just need to do connection between those two. I am not supposed to change the code in Page2 however can change the code in Page1.

I'll check this and let you know. Thanks once again.

Hey János,

Its working perfectly. But I have done some changes in first UI page.

Added code in first UI page HTML:

<g:evaluate var="jvar_sysid">
			var idForSecondPage = RP.getWindowProperties().get('sysId');
			idForSecondPage;
		</g:evaluate>
		
		<table>
			<tr id="dialog_buttons">
				<td colspan="2" align="left">
					<g:dialog_buttons_ok_cancel cancel_type="button" ok_id="task_id" ok="partUsage('${jvar_sysid}')" ok_type="button"/>
				</td>
			</tr>
		</table>

Special thanks to you @Ankur Bawiskar for your time.