How to create UI action and UI page script to show catalog tasks in glidedialogwindow

FaizDev101
Tera Expert

Created UI action button in RITM. If click on that it should show Glide dialog window, which shows catalog tasks.

 

 

1 ACCEPTED SOLUTION

@FaizDev101 

 

This is tried and tested solution I have created in my PDI and it worked really well, Please check:

 

Please follow all the steps it will work for you and also please make sure you are using name of your instance script includes and ui pages:

 

UI ACTION - client checked (should be client side):

 

PRINCE_ARORA_0-1680266453691.png

 

var gm = new GlideModal("button", false, 'modal-sm');
gm.setTitle("Tasks:");
gm.setPreference("sysparm_ID", g_form.getUniqueValue());
gm.setWidth(550);
gm.render();

 

UI PAGE  - button (name of ui page):

 

PRINCE_ARORA_2-1680266715967.png

 

 

HTML:

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="iframee"></div>
</j:jelly>

 

 

Client Script:

 

var $j = jQuery.noConflict();
var ga = new GlideAjax('CountActiveEmployees');
ga.addParam('sysparm_name', 'getTasks');
ga.addParam('sysparm_sys_id', g_form.getUniqueValue());
ga.getXML(parseResponse);

function parseResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
var str = "<div><table class='table' id='tableData'><tr><th>Number</th><th>Short Description</th></tr>";
answer = JSON.parse(answer);
for (var i = 0; i < answer.length; i++) {
str = str + '<tr id="tableRow"><td>' + answer[i].number +'</td><td>' + answer[i].short_description + '</td></tr>';
}
$j('#iframee').append(str);
}

 

 

Script Include - should be client callable because we are making GlideAjax call:

 

 getTasks: function() {
var gr = new GlideRecord("sc_task");
gr.addQuery('request_item', this.getParameter("sysparm_sys_id"));
gr.query();
var arr = [];
while (gr.next()) {
var json = {
"number": gr.number+"",
"short_description": gr.short_description+""
};
arr.push(json);
}
return JSON.stringify(arr);

}

 

PRINCE_ARORA_1-1680266675862.png

 

 

OUTPUT:

 

PRINCE_ARORA_3-1680266764766.png

 

Please mark the response as correct or helpful if this has answered your query!

 

View solution in original post

3 REPLIES 3

Prince Arora
Tera Sage
Tera Sage

@FaizDev101 ,

 

If I suggest you some different logic instead of jelly using javascript with same functionality or do you want to go with above mentioned approach only? 

Please let me know if it will work for you I will share the logic

 

 

however i want to use UI pages, you can suggest your logic pls

@FaizDev101 

 

This is tried and tested solution I have created in my PDI and it worked really well, Please check:

 

Please follow all the steps it will work for you and also please make sure you are using name of your instance script includes and ui pages:

 

UI ACTION - client checked (should be client side):

 

PRINCE_ARORA_0-1680266453691.png

 

var gm = new GlideModal("button", false, 'modal-sm');
gm.setTitle("Tasks:");
gm.setPreference("sysparm_ID", g_form.getUniqueValue());
gm.setWidth(550);
gm.render();

 

UI PAGE  - button (name of ui page):

 

PRINCE_ARORA_2-1680266715967.png

 

 

HTML:

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="iframee"></div>
</j:jelly>

 

 

Client Script:

 

var $j = jQuery.noConflict();
var ga = new GlideAjax('CountActiveEmployees');
ga.addParam('sysparm_name', 'getTasks');
ga.addParam('sysparm_sys_id', g_form.getUniqueValue());
ga.getXML(parseResponse);

function parseResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
var str = "<div><table class='table' id='tableData'><tr><th>Number</th><th>Short Description</th></tr>";
answer = JSON.parse(answer);
for (var i = 0; i < answer.length; i++) {
str = str + '<tr id="tableRow"><td>' + answer[i].number +'</td><td>' + answer[i].short_description + '</td></tr>';
}
$j('#iframee').append(str);
}

 

 

Script Include - should be client callable because we are making GlideAjax call:

 

 getTasks: function() {
var gr = new GlideRecord("sc_task");
gr.addQuery('request_item', this.getParameter("sysparm_sys_id"));
gr.query();
var arr = [];
while (gr.next()) {
var json = {
"number": gr.number+"",
"short_description": gr.short_description+""
};
arr.push(json);
}
return JSON.stringify(arr);

}

 

PRINCE_ARORA_1-1680266675862.png

 

 

OUTPUT:

 

PRINCE_ARORA_3-1680266764766.png

 

Please mark the response as correct or helpful if this has answered your query!