The CreatorCon Call for Content is officially open! Get started here.

If statement in UI Page HTML

ktjstn
Kilo Expert

Hi!

I have this if statement in my UI Page HTML that will look for the value of the parent priority. If the parent priority = 1, then the reference field will populate only those Director/VP users. If the parent priority = 2, then the reference field will populate Director/VP/Manager users. But the problem is it's just populating the  Director/VP/Manager users even if the parent priority is 1:

Here are my scripts:

//UI ACTION

function approvedBy(){

	var parent_priority = g_form.getValue('parent.priority');
	
 	var parent = new GlideDialogWindow('approved_by');
	parent.setTitle('Approved By');
	parent.setPreference('rfc_sys_id', g_form.getUniqueValue());
	parent.setPreference('parent_priority', parent_priority);
	
	parent.render();
	

}

 

//UI PAGES

HTML:

<?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 >
		
		<!-- Get the RFC number -->
		<input type="hidden" name="rfc_sys_id" value="${RP.getWindowProperties().get('rfc_sys_id')}" />
		
		<!-- Get the parent priority -->
		<input type="hidden" name="parent_priority" value="${RP.getWindowProperties().get('parent_priority')}" />


		
		<h5>Please select an approver.</h5>

		<g:evaluate var="jvar_gr" object="true">
			var gr = new GlideRecord("change_request");
			gr.addQuery('sys_id', rfc_sys_id);
			gr.addQuery('parent.priority', 1);
			gr.query();
			gr;
		</g:evaluate>

		<j:choose>
			
			<!-- If parent priority == 1 -->
			
			<j:when test="${jvar_gr.hasNext()}"><g:ui_reference name ="p1_approver" id="p1_approver" table="sys_user" query="titleSTARTSWITHVP^ORtitleSTARTSWITHDirector^ORtitleSTARTSWITHDir^active=true" /></j:when>
			
			<!-- If parent priority != 1 -->
			
			<j:otherwise><g:ui_reference name ="p2_approver" id="p2_approver" table="sys_user" query="titleSTARTSWITHVP^ORtitleSTARTSWITHDirector^ORtitleSTARTSWITHDir^ORtitleSTARTSWITHManager^ORtitleSTARTSWITHMgr^active=true" /></j:otherwise>
		</j:choose>



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

	</g:ui_form>

</j:jelly>

 

2 REPLIES 2

Community Alums
Not applicable

Can you simply try change 

<j:when test="${jvar_gr.hasNext()}">

to

<j:when test="${jvar_gr.next()}">

And see if that helps.

Hi Aidan,

It's still not working 😞