- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 05:05 AM - edited 03-31-2023 07:09 AM
Created UI action button in RITM. If click on that it should show Glide dialog window, which shows catalog tasks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 05:48 AM - edited 03-31-2023 05:49 AM
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):
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):
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);
}
OUTPUT:
Please mark the response as correct or helpful if this has answered your query!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 05:35 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 05:37 AM
however i want to use UI pages, you can suggest your logic pls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 05:48 AM - edited 03-31-2023 05:49 AM
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):
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):
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);
}
OUTPUT:
Please mark the response as correct or helpful if this has answered your query!