- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 02:15 AM - edited 03-13-2025 08:14 PM
Hi Experts,
I have a requirement. On an incident form we have a field called "Caused By Change". The requirement is on the closed incidents we need to created a button when clicked, opens a pop-up or modal and that window should populate the incident form "Caused By Change" value. if Caused by change is not having any value then we need to select existing Change Requests. I tried this by creating a UI action, UI page and called script include in the client script of UI page. However there is no luck. Need your expertise here. I cant paste the code here due to our project restriction. Its little critical
Thanks in advance.
@Ankur Bawiskar I saw you helped many people need your advice here as well.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 04:18 AM
this worked for me
Send the sysId and display value as well and set both
function showModal() {
var gm = new GlideDialogWindow('showchangerequest');
gm.setTitle('My UI page');
gm.setSize(600,600); //Set the dialog size
gm.setPreference('sysparm_changesysid', g_form.getValue('caused_by'));
gm.setPreference('sysparm_changenumber', g_form.getDisplayBox('caused_by').value);
gm.render();
}
Please enhance from your side.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<g:ui_form>
<g:evaluate var="jvar_changeSysId" expression="RP.getWindowProperties().get('sysparm_changesysid')" />
<g:evaluate var="jvar_changenumber" expression="RP.getWindowProperties().get('sysparm_changenumber')" />
<input type="hidden" id="changerequest1" name="changerequest1" value="${jvar_changeSysId}"></input>
<div id='mydiv3'>
<label id='label3'>Change Request</label>
<g:ui_reference name="changerequest" id="changerequest" table="change_request" value="${jvar_changeSysId}" displayValue="${jvar_changenumber}" style="width:180px"/>
</div>
</g:ui_form>
</html>
</j:jelly>
Output:
I hope I have answered your question and you can enhance it further
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 02:27 AM
this link has logic on how to set the reference field on UI page. ensure you pass the field value from UI action.
if the field has value then set it or else don't set
Store value in reference field of ui page using client script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader