UI Page issue - not getting variable being passed in

Aoife Lucas
Giga Expert

Having issues with calling UI Page from a Client Script out of Problem form.  The popup dialog appears but I'm trying to pass in a variable with setPreference, have verified that variable has the appropriate value prior to calling GlideDialogWindow.  Using g:evaluate to get it back in the HTML of the UI Page but my variable is null.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (newValue === '4') {
	   try {
		   var problemNumber = g_form.getValue('number').toString();
		   var gm = new GlideDialogWindow('x_sor_prb_inc_upd_SOR_Incident_Categorization_from_Problem', false, 600);
		   gm.setTitle('Update all associated incidents');
		   gm.setPreference("problem_number", problemNumber);
		   gm.render();
		} catch (ex) {
			alert(ex.message);
		}
   }

   //Type appropriate comment here, and begin script below
   
}
<?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:requires name="styles/heisenberg/heisenberg_all.css" includes="true" />
	
	<g:ui_form id="SOR_Incident_Categorization_from_Problem">

		<style type="text/css">
			#categorization_dialog_footer input {
				width: 100%;
			}
			#info_message {
				margin-left:10px;
				color:#667
			}
		</style>
		
		<g:evaluate var="jvar_problem_number"
			expression="RP.getWindowProperties().get('problem_number')"/>
		<table>
			<tr>
				<td>${jvar_problem_number}</td>
			</tr>
		</table>
		
	</g:ui_form>
</j:jelly>
1 ACCEPTED SOLUTION

That line works for you? Very strange as, for me, in a Madrid instance, that line returns undefined yet :

<g:evaluate var="jvar_problem_numberexpression="RP.getWindowProperties().get('problem_number')"/>

Returns exactly what I pass. 

Well, glad you could find the solution! 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

7 REPLIES 7

The note I found in the docs

Note: For scoped applications, the RP.getWindowProperties.get() method is not available. Instead use the syntax RP.getWindowProperties.<property>, where <property> is the dialog box property that you want to obtain. For example, RP.getWindowProperties().get('title') would be RP.getWindowProperties().title.

It has to do with being a scoped app.  And these days, I'll be darned if I can understand why you would make any changes without a scoped app.  You gain so much including versioning and GitHub repos.  Why not?

Very interesting! I was actually perplexed by it all so I spun up a scoped app and saw the same behavior. I kind of suspected scope was somehow the issue but, well, that confirms it! 

On a side note I also found that this seems to work, which I didn't see documented anywhere obvious. 

//Calling the test page
var uip = new GlideModal("x_16112_test2");
uip.setPreference('sysparm_id', 'Value of ID');
uip.render();

With this line: 

<g:evaluate var="jvar_sys_id" expression="'${sysparm_id}'"/>

Works like charm

find_real_file.png

Go figure!

 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

I want to thank you for sharing this, because I struggled with the same problem until I found your answer