Variable is not working in UI page in HTML

sasi
Tera Contributor

Hi team, 

 

My requirement is based on assignment group i want to to restrict options in pop window that is created from UI page.

UI page 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"> 
 
 
 
<j:set var="jvar_close_reason_val" value="${RP.getWindowProperties().get('sysparm_close_val')}"/>
<j:set var="jvar_close_reason_display_val" value="${RP.getWindowProperties().get('sysparm_close_disp')}"/>
<j:set var="jvar_close_action" value="${RP.getWindowProperties().get('sysparm_close_action')}"/>
 
<g:evaluate var="jvar_assignmentgroup" expression="${RP.getWindowProperties().get('sysparm_assignmentgroup')}" />
<input type="hidden" id='close_action'  value="${jvar_close_action}" />
       
<g:evaluate>
<td><tr>${jvar_assignmentgroup}</tr></td>
var reason = new GlideRecord("sys_choice");
var roleProp = gs.getProperty('x_wms_assignemtn_group_role');
var grp = '${jvar_assignmentgroup}';
var roleGrp = new GlideRecord('sys_group_has_role');
roleGrp.addEncodedQuery('role=' + roleProp + '^group=' + grp);
roleGrp.query();
if (!roleGrp.hasNext()) {
reason.addEncodedQuery('name=management^element=reason^inactive=false');
reason.query();
} else {
reason.addEncodedQuery('name=management^element=reason^inactive=false^value=expense line');
reason.query();
}
</g:evaluate>
 
<g:ui_choice_input_field id="choice_id" name="choice_name" label="Select Closure Reason"> 
<option value="${jvar_reason_val}">${jvar_reason_display_val}</option> 
<j:while test = "${reason.next()}">
<option value="${reason.getValue('value')}">${reason.getValue('label')}</option> 
</j:while>
</g:ui_choice_input_field> 
 
<tr id="dialog_buttons">
        <td colspan="2" align="right">
<br/><br/>
<div class="text-center">
<button id='yes' class="action_context btn btn-primary" style="margin-left:1px;padding:9px 30px;" onclick="CloseReason()">${gs.getMessage('Yes')}</button>
<button id='no' class="action_context btn btn-primary" style="margin-left:55px;padding:9px 30px;" onclick="onCancel()">${gs.getMessage('No')}</button>
</div>
        </td>
     </tr>
</j:jelly>
 
Client scr:
 
                        var closeReason = new GlideModal('uipage', false);
                        closeReason.setTitle("please select?");
                        closeReason.setPreference("sysparm_close_val", g_form.getValue("reason"));
                        closeReason.setPreference("sysparm_close_disp", g_form.getDisplayValue("reason")); // 
                        closeReason.setPreference("sysparm_close_action", "close");
closeReason.setPreference("sysparm_assignmentgroup", g_form.getValue("assignment_group"));
closeReason.setPreference("testval", "yes");
                        closeReason.setSize(500, 800);
                        closeReason.render();
                        return false;
                    
4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@sasi 

so what's the outcome and what's the issue?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@sasi 

few corrections

1) g:evaluate cannot include HTML tags

2) where is this defined? jvar_reason_display_val and jvar_reason_val

both the variables I could not find

<option value="${jvar_reason_val}">${jvar_reason_display_val}</option>

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

My issue is i am not getting assignment group value, 

these two 2 defined at starting of the code, by mistake "close" removed

<j:set var="jvar_close_reason_val" value="${RP.getWindowProperties().get('sysparm_close_val')}"/>
<j:set var="jvar_close_reason_display_val" value="${RP.getWindowProperties().get('sysparm_close_disp')}"/>
<j:set var="jvar_close_action" value="${RP.getWindowProperties().get('sysparm_close_action')}"/>
 
can you let md know what i need to do to get that group.

@sasi 

So what's the issue?

Did you check by adding gs.info() in the g:evaluate where you are using GlideRecord whether you are able to get row count or not?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader