- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2019 10:26 PM
Hi,
I have created a UI action 'Copy Attachments' which I have extended to the Agent Workspace. Since GlideWindow do not work in Agent Workspace hence I have use g_modal to open a popup. Issue is I am unable to close the popup upon submission . I have been using GlideDialogWindow.get().destroy() in the client script of the UI page but this doesnt seems to work any more .
Please find The code :-
UI Action :-
function onClick(g_form) {
var f = {};
f.title = 'Please select the Attachments to Copy to Email Client';
f.url = 'AWS_Client_Attachments.do?sysparm_sys_id='+ g_form.getUniqueValue();
f.size = "lg";
// display frame
g_modal.showFrame(f).then(function() {});
}
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">
<j:set var="jvar_sysid" value="${sysparm_sys_id}"/>
<g:evaluate var="jvar_att" jelly="true" object="true">
var arr = [];
var records = [];
var att = new GlideRecord("sys_attachment");
att.addEncodedQuery("table_sys_id=" + jelly.jvar_sysid);
att.orderBy("file_name");
att.query();
while(att.next())
{
arr.push(att.file_name.toString());
records.push(att.sys_id.toString());
}
var arr1 = '';
var records1 = '';
for(var i=0;i<arr.length;i++)
{
if(i == 0)
records1 = records[i];
else if(arr[i] != arr[i-1])
{
records1 = records1 + ',' + records[i];
}
}
var att1 = new GlideRecord("sys_attachment");
att1.addEncodedQuery("sys_idIN" + records1);
att1.query();
att1;
</g:evaluate>
<j2:if test="${jvar_att.hasNext()}">
<j:while test="${jvar_att.next()}">
<g:ui_checkbox name='related_attachment:${jvar_att.getValue("sys_id")}' value='${jvar_att.getValue("file_name")}' class='attachment_checkbox'>${jvar_att.getValue("file_name")}</g:ui_checkbox><br/>
</j:while>
</j2:if>
<br/>
<button onclick="myFunctionSubmit()">Ok</button>
<button onclick="myFunctionCancel()">Cancel</button>
</j:jelly>
UI Page Client Script:-
function myFunctionSubmit(){
var x = $$('.attachment_checkbox[value=true]'); //array of the checkbox elements
if(x.length == 0)
{
alert("Please select an attachment");
return false;
}
else if (x.length > 0)
{
var list_of_attchs_ids = '';
var attch_name = '';
for (var j=0; j< x.length; j++) {
//get the sys_id of the attachment from the checkbox element name
attch_name = x[j].name.split(':');
if (list_of_attchs_ids=='')
list_of_attchs_ids = attch_name[1];
else
list_of_attchs_ids = list_of_attchs_ids + ','+ attch_name[1];
}
var ajax = new GlideAjax("getAttachmentLists");
ajax.addParam("sysparm_name","updateAttachmentList");
ajax.addParam("sysparm_attachmentsysid",list_of_attchs_ids);
ajax.getXMLWait();
}
// var ticket_id = g_form.getUniqueValue();
// var table_name = g_form.getTableName();
// var newURL = 'email_client.do?sysparm_table=' + table_name + '&sysparm_sys_id='+ ticket_id +'&sysparm_target=' + table_name + '&sys_target=' + table_name + '&sys_uniqueValue=' + ticket_id +
// '&sys_row=0&sysparm_encoded_record='; //build the URL of the email client window
//alert(newURL);
//popupOpenEmailClient(newURL); //opens the email client
GlideDialogWindow.get().destroy(); //to automatically close the window
}
function myFunctionCancel()
{
GlideDialogWindow.get().destroy();
}
I have got this from the post - Select specific attachments to copy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2020 11:14 PM
Hi,
I did a small change in both the ui action script and added 'return true' for both the Submit and Cancel Functions in the Client script of the UI page
UI Script
function onClick(g_form) {
g_modal.showFrame({
title: 'Please select the Attachments to Copy to Email Client',
url: 'Email_Client_Attachments_AW.do?sysparm_sys_id=' + g_form.getUniqueValue(),
size: 'lg'
});
}
UI Page Client Script
function myFunctionSubmit(){
var x = $$('.attachment_checkbox[value=true]'); //array of the checkbox elements
if(x.length == 0)
{
alert("Please select an attachment");
return false;
}
else if (x.length > 0)
{
var list_of_attchs_ids = '';
var attch_name = '';
for (var j=0; j< x.length; j++) {
//get the sys_id of the attachment from the checkbox element name
attch_name = x[j].name.split(':');
if (list_of_attchs_ids=='')
list_of_attchs_ids = attch_name[1];
else
list_of_attchs_ids = list_of_attchs_ids + ','+ attch_name[1];
}
var ajax = new GlideAjax("getAttachmentLists");
ajax.addParam("sysparm_name","updateAttachmentList");
ajax.addParam("sysparm_attachmentsysid",list_of_attchs_ids);
ajax.getXMLWait();
}
var ticket_id = g_form.getUniqueValue();
var table_name = g_form.getTableName();
var newURL = 'email_client.do?sysparm_table=' + table_name + '&sysparm_sys_id='+ ticket_id +'&sysparm_target=' + table_name + '&sys_target=' + table_name + '&sys_uniqueValue=' + ticket_id +
'&sys_row=0&sysparm_encoded_record='; //build the URL of the email client window
popupOpenEmailClient(newURL); //opens the email client
return true;
}
function myFunctionCancel()
{
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 02:36 AM
Hi Avik,
I have the same issue, did you find the solution?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2020 11:14 PM
Hi,
I did a small change in both the ui action script and added 'return true' for both the Submit and Cancel Functions in the Client script of the UI page
UI Script
function onClick(g_form) {
g_modal.showFrame({
title: 'Please select the Attachments to Copy to Email Client',
url: 'Email_Client_Attachments_AW.do?sysparm_sys_id=' + g_form.getUniqueValue(),
size: 'lg'
});
}
UI Page Client Script
function myFunctionSubmit(){
var x = $$('.attachment_checkbox[value=true]'); //array of the checkbox elements
if(x.length == 0)
{
alert("Please select an attachment");
return false;
}
else if (x.length > 0)
{
var list_of_attchs_ids = '';
var attch_name = '';
for (var j=0; j< x.length; j++) {
//get the sys_id of the attachment from the checkbox element name
attch_name = x[j].name.split(':');
if (list_of_attchs_ids=='')
list_of_attchs_ids = attch_name[1];
else
list_of_attchs_ids = list_of_attchs_ids + ','+ attch_name[1];
}
var ajax = new GlideAjax("getAttachmentLists");
ajax.addParam("sysparm_name","updateAttachmentList");
ajax.addParam("sysparm_attachmentsysid",list_of_attchs_ids);
ajax.getXMLWait();
}
var ticket_id = g_form.getUniqueValue();
var table_name = g_form.getTableName();
var newURL = 'email_client.do?sysparm_table=' + table_name + '&sysparm_sys_id='+ ticket_id +'&sysparm_target=' + table_name + '&sys_target=' + table_name + '&sys_uniqueValue=' + ticket_id +
'&sys_row=0&sysparm_encoded_record='; //build the URL of the email client window
popupOpenEmailClient(newURL); //opens the email client
return true;
}
function myFunctionCancel()
{
return true;
}