UI Action

RohanK1004
Tera Contributor

I want to create a UI Action on the Incident form with a form button labeled 'Show Summary'. When clicked, the button should display the Caller, Short Description, Priority, and State fields in a dialog window. Please guide me on how to do this.

2 REPLIES 2

James Schwab
Tera Guru

Hi Yuvaraj,

You can achieve by showing a GlideModal in your UI Action.

 

Your UI Action will look something like this:

function onClick() {
    var gm = new GlideModal("glide_info", true, 600);
    gm.setTitle("Test title");
    gm.setPreference("title", "The description is:" + g_form.getValue('description'));
    gm.setPreference("onPromptComplete", function() {
        alert("You clicked on 'Ok'");
    });
    gm.render();
}


The UI action might look like this:

JSchwab_0-1733382358540.png


Which will give you a UI action like below!

JSchwab_1-1733382378847.png

 

Sanjay191
Tera Sage

Hello @RohanK1004 

Please Refer below logic 
Create a ui page like below and call in ui action by using the GlideDialogWindow api and pass the sys_id by setPreference('sysparm_sys_id',g_form.getUniqueValue()) and pass the UI page name that you want to show details of the incident records.
Make the Required Changes accordingly

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">
<g:evaluate var="sysparm_sys_id">
var sysparm_sys_id = RP.getParameterValue("sysparm_sys_id");
sysparm_sys_id;
</g:evaluate>

<g:evaluate var="jvar_record" object="true" jelly="true">
var gr = new GlideRecord("incident");
if (gr.get(sysparm_sys_id)) {
gr;
}
</g:evaluate>

<style>
td {
font-size: 8px;
text-align: center;
vertical-align: top;
}
@media print {
@page {
margin: 0;
}
}
</style>

<table style="width:100%; height:100%">
<tr>
<td>State:</td>
<td>${jvar_record.getDisplayValue('state')}</td>
</tr>
<tr>
<td>Caller:</td>
<td>${jvar_record.getDisplayValue('caller_id')}</td>
</tr>
<tr>
<td>Short Description:</td>
<td>${jvar_record.getDisplayValue('short_description')}</td>
</tr>
<tr>
<td>Priority:</td>
<td>${jvar_record.getDisplayValue('priority')}</td>
</tr>
</table>
</j:jelly>


If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You