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

Michael Jones -
Giga Sage

I can't identify anything in your code that would cause an issue. I would first try passing a hardcode value for problemNumber in your client-script (just be absolutely sure) and if you still see null,  also try a hardcoded value in your jelly 

<g:evaluate var="jvar_problem_number"
expression="'hardcoded value'"/>

If you know you are passing a hardcoded value and your original expression is not pulling it in, but in your next test you see the hardcoded value you put inside your evaluate line, then maybe there is an issue with scope? I see you are calling a UI page from a scoped application but, I can't really think of a reason that would cause what you are experiencing. 

Do you have any other scenarios like that this are working?

Sorry I don't have an answer!

 

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

 

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

Aoife Lucas
Giga Expert

Interesting:  Changed the evaluate to

<g:evaluate var="jvar_problem_number" expression="problemNumber"/>

The output is still null when I use ${jvar_problem_number}. 

Marshall

Aoife Lucas
Giga Expert

Found it:

<g:evaluate var="jvar_problem_number" expression="RP.getWindowProperties().problem_number"/>

works per https://docs.servicenow.com/bundle/helsinki-application-development/page/script/client-scripts/refer...

Odd that it is on a Helsinki page I've been using Madrid docs as that is my current version.

Aoife

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!