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

Ankur Bawiskar
Tera Patron
Tera Patron

@Surbhi Srivasta 

so you want to auto-populate the reference input in UI page with the current record's sys_id?

why not do this when you call that UI page

are you calling the UI page from UI action? share that UI action script here

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

@Ankur Bawiskar 

Yes that is an correct understanding. I am calling my UI Page from UI Action only.

 

I tried passing the sys_id of the record from my UI Action only and tried setting it in UI Page but it is not working.

 

Below is my code version which I have tried. It is setting the value as I can see the " Record Preview ICON", it is just not showing the value in the Reference Box.

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_record_table', g_form.getTableName());
	dd.render();
}

UI Page:

<g:evaluate var="jvar_current" expression="RP.getParameterValue('sysparm_record')"/>
<g:evaluate var="jvar_current_table" expression="RP.getParameterValue('sysparm_record_table')"/>
<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" displayvalue="${jvar_current_display}" table="incident"  />
</tr>
</table>

Please assist

@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

Hi @Ankur Bawiskar 

 

Can you please help me on the below thread:

https://www.servicenow.com/community/developer-forum/ui-page-dialog-window-size/m-p/2572452#M1001080

 

I am able to get most of the things on my page but size of the dialog is an issue. Please assist!!