- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 01:32 AM
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:
Please assist.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 03:55 AM
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>
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 01:46 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 03:37 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 03:55 AM
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>
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 04:30 AM
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!!