The CreatorCon Call for Content is officially open! Get started here.

How can I export multiple tables with GwtPollDialog

hartr
Giga Contributor

I am using GwtPollDialog to export a table to a spreadsheet. As it appears that I can't export multiple tables at the same time in servicenow I want to trigger the GwtPollDialog function a second time once the first dialog has closed.

Can anyone help re the script needed to detect the first dialog is closed so that the second dialog can be initiated ?

thanks

13 REPLIES 13

The customer already has the "Windows and Changes" schedule page and wants to be able export the data so they can email to their management (rather than to manipulate the data). They can't get a visual export (apart from doing a screenshot) so being able to export the tabular data to excel is the next best option.


Take a look at scheduled export sets and see if it meets your requirements. If you are not on Helsinki yet, add this to your list of reasons to upgrade.


So there isn't a way of detecting the that the export dialog has closed ? maybe using .bind ?


Hi Russell,



I didn't say there wasn't a way, only that I don't know of a way. Be cautious of using DOM manipulation in client scripts as it can cause upgrade issues.



Client Script Best Practices - ServiceNow Wiki


Hi I have 1 core table and 10 related tables (relationship built based on reference field in the parent table.

Requirement is to build custom Export button and when user will click on that button, along with Parent table data, all related table data should also be exported.

I am getting dynamically each table name and query in the for loop and passing value dynamically  in the 

dialog = new GwtPollDialog(oddTableList, evenQuery, rows, view, 'unload_excel_xlsx');

But when I am clicking on Export button, it is returning data for 1 table only.

UI Action --

var ga = new GlideAjax('VFdpdExport');
ga.addParam('sysparm_name', 'grRelatedTables');
ga.addParam('sysparm_prd_name', g_list.tableName);
ga.addParam('sysparm_query',query);
ga.getXML(grAllRelatedTables);

function grAllRelatedTables(response) {
var answer = response.responseXML.documentElement.getAttribute("answer").toString();
if(answer){
answer = answer.split('#');
for(var i =0;i<answer.length;i++){
if(i%2 != 0) {
evenQuery = answer[i];
if(!evenQuery){
return;
}

alert('evenQuery:'+evenQuery);
}
else{
oddTable = answer[i];
oddTableList =oddTable.replace(',','');
if(!oddTableList){
return;
}
alert('oddTableList : '+oddTableList);

}

dialog = new GwtPollDialog(oddTableList, evenQuery, rows, view, 'unload_excel_xlsx');
dialog.execute();

}
return;

}
}

 

Script Include --

grRelatedTables : function(){
var prdTab = this.getParameter('sysparm_prd_name');
var encodedQuery = this.getParameter('sysparm_query');
var allRelatedTab = [];
var getRelatedTab = new GlideRecord('u_dpd_export_framework');
getRelatedTab.addQuery('u_core_table.name',prdTab);
getRelatedTab.addQuery('u_active',true);
getRelatedTab.query();
while(getRelatedTab.next()){
allRelatedTab.push(getRelatedTab.u_related_table.name + '#' + getRelatedTab.u_related_column+'.'+encodedQuery + '#');
//allRelatedTab.push('/');
}

return allRelatedTab.toString();
},