Display value of a Reference Field not setting up in UI Page

Surbhi Srivasta
Tera Expert

Hi,

 

I have a reference input defined in my UI Page.

 

I this reference input I want to set the current record value which is not happening. So far I have tried as below:

 

HTML:

<g:evaluate var="jvar_current" expression="RP.getParameterValue('sysparm_record')"/> //I am passing this from my UI Action
<g:ui_reference name="rec_details" id="rec_details" value="jvar_current" displayvalue="${jvar_current_display}" table="incident"  />

Client Script in UI Page:

gel("rec_details").value = g_form.getUniqueValue();

 

Output coming: A record is getting linked but it is not displaying the record. Please see below:

 

SurbhiSrivasta_0-1685089787310.png

 

 

Please assist.

1 ACCEPTED SOLUTION

@Surbhi Srivasta 

update as this and it will work fine.

UI Action

function openPage() {

	var dd = new GlideDialogWindow('UI Page Name');
	//dd.setTitle(getMessage(""));
	dd.setWidth(800);
	dd.setPreference('sysparm_record', g_form.getUniqueValue());
	dd.setPreference('sysparm_recordDisplayValue', g_form.getValue('number'));
	dd.setPreference('sysparm_record_table', g_form.getTableName());
	dd.render();
}

UI Page HTML:

<g:evaluate var="jvar_current" expression="RP.getParameterValue('sysparm_record')"/>
<g:evaluate var="jvar_current_table" expression="RP.getParameterValue('sysparm_record_table')"/>
<g:evaluate var="jvar_currentRecordDisplayValue" expression="RP.getParameterValue('sysparm_recordDisplayValue')"/>

<table>
<tr>
<td style="width:25%;padding:5px;">
<g:form_label>Preview Record</g:form_label>
</td>
</tr>
<tr>
<td class ="paddingBetweenCols" style="width:60%">
<g:ui_reference name="rec_details" id="rec_details" value="${jvar_current}" table="${jvar_current_table}" displayValue="${jvar_currentRecordDisplayValue}"/>
</tr>
</table>

 

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

View solution in original post

6 REPLIES 6

Anil Lande
Kilo Patron

Hi,

Your UI Page script should be like this:

<?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:evaluate var="jvar_current" expression="RP.getParameterValue('sysparm_record') "/> //I am passing this from my UI Action
	<g:evaluate var="jvar_current_display" expression="RP.getParameterValue('jvar_current_display')"/>  // make sure to set jvar_currenty_display value using evalaute by passing that parameter from UI Action
<g:ui_reference name="rec_details" id="rec_details" value="${jvar_current}" table="incident" displayValue="${jvar_current_display}"/>

</j:jelly>

 

Screenshot 2023-05-26 at 3.18.56 PM.png

 

Getting it like above.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

@Anil Lande 

Thanks for your input. Suggestion provided did not worked for me. Please find the updates which I have done

Please let me know if I am missing something here:

 

Display value for this table is "Number" on Incident table for us.

 

UI Action code:

function openPage() {
	
    var dd = new GlideDialogWindow('UI Page Name');
    //dd.setTitle(getMessage(""));
    dd.setWidth(800);
	dd.setPreference('sysparm_record', g_form.getUniqueValue());
	dd.setPreference('sysparm_record_table', g_form.getTableName());
	dd.setPreference('jvar_current_display', g_form.getValue('number'));
	dd.render();
}

UI HTML:

<g:evaluate var="jvar_current" expression="RP.getParameterValue('sysparm_record')"/>
<g:evaluate var="jvar_current_table" expression="RP.getParameterValue('sysparm_record_table')"/>
<g:evaluate var="jvar_current_display" expression="RP.getParameterValue('jvar_current_display')"/> 
<table>
<tr>
<td style="width:25%;padding:5px;">
		<g:form_label>Preview Record</g:form_label>
</td>
</tr>
<tr>
<td class ="paddingBetweenCols" style="width:60%">
			<g:ui_reference name="rec_details" id="rec_details" value="${jvar_current}" table="incident" displayValue="${jvar_current_display}"/>
</tr>
</table>