- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2019 08:18 AM
Hi folks,
I am struggling with a UI business need:
business need : on a List View e.g.Incident list, when a user wants to export a file in CSV, a Warning message pops up warning the user that he is about to export sensitive data, for further information he can even copy and paste a URL.
On that message, a "OK" button is available and enables the user to proceed with the CSV export.
my implementation :
- UI context "CSV" calls a UI page
- the UI page contains the Warning message in HTML format as well as a Client script to trigger the CSV export box.
Result: the warning message pops up correctly but the CSV export box does not appear.
Step 1 : Incident list, export CSV
Step 2 : The Warning message pops up right away
Step 3: I select OK -> Failure, the CSV export is not carried out. Apprently, the g_list that enables the user to export data is not recognized in the context anymore.
expected result for Step3:
Here are my scripts:
Context Menu CSV - Action Script
var dialog = new GlideDialogWindow("export_csv"); //Render the dialog containing the UI Page 'cancellation_reason'
dialog.setTitle("<center> Dsiclaimer </center>"); //Set the dialog title
dialog.render(); //Open the dialog
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">
<g:ui_form>
<table width="100%">
<tr>
<td><center> Warning - Export notice</center><br />
<br />
You are about to export sensitive data. you are <i> <strong>   responsible   </strong> </i> for the records exported.<br />
<br />
Please check the Confidentiality terms :<br />
<i><u>https://confidentiality.terms.com</u></i><br />
<br />
</td>
</tr>
<tr id="dialog_buttons">
<td colspan="2" align="right">
<!-- Pull in 'dialog_buttons_ok_cancel' UI Macro for submit/cancel buttons.
'ok' option will call the 'runContextAction' Client script function from the UI Page-->
<g:dialog_buttons_ok_cancel ok="return runContextAction()" ok_type="button" cancel_type="button"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
UI page - Client Script
function runContextAction() {
// confirm("client script export CSV");
var sysparm_rows = g_list.grandTotalRows;
var num_rows = parseInt(sysparm_rows);
var sysparm_query = g_list.getQuery({orderby: true, fixed: true});
var sysparm_view = g_list.view;
if (num_rows < g_export_warn_threshold) {
var dialog = new GwtPollDialog(g_list.tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_csv');
dialog.execute();
return;
}
var dialogB = new GwtExportScheduleDialog(g_list.tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_csv');
dialogB.execute();
}
Note : At first I proposed a confirm box "confirm()" to avoid the UI page but on Chrome, the user cannot select the URL on the confirm box and I cannot render HTML formats such as Bold, Underline....text. Therefore I have dropped the Confirm box.
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 07:44 AM
Thank you Ankur and Laurent for your help, after serveral attempts I have completed this story successfully:
I send g_list inputs from the context menu to my UI page
and I retrieve on my UI page
This way I can call g_list object from my UI page and launch the export dialog box thereafter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2019 08:45 AM
Hi,
I think g_list won't work in the UI page client script. Can you try to hard code the value for table name, number of rows, view name
I tried by giving hard coded value and it is working
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2019 10:28 AM
I would suggest you to call the client script inside the context menu to have the right scope for the g_list.
To do so, add the following to your dialog object:
dialog.setPreference('onPromptComplete', function(){
var sysparm_rows = g_list.grandTotalRows;
var num_rows = parseInt(sysparm_rows);
var sysparm_query = g_list.getQuery({orderby: true, fixed: true});
var sysparm_view = g_list.view;
if (num_rows < g_export_warn_threshold) {
var dialog = new GwtPollDialog(g_list.tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_csv');
dialog.execute();
return;
}
var dialogB = new GwtExportScheduleDialog(g_list.tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_csv');
dialogB.execute();
});
Now modify the runContextAction function from the UI page to actually call the prompt complete:
function runContextAction() {
var gdw = GlideDialogWindow.get();
var f = gdw.getPreference('onPromptComplete');
if (typeof(f) == 'function') {
try {
f.call(gdw);
} catch(e) {
}
}
else
gdw.destroy();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 07:44 AM
Thank you Ankur and Laurent for your help, after serveral attempts I have completed this story successfully:
I send g_list inputs from the context menu to my UI page
and I retrieve on my UI page
This way I can call g_list object from my UI page and launch the export dialog box thereafter.