- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2017 05:21 PM
I freely admit to begging for help from the mighty ctomasi and/or anyone else who can help
I have an email script that, in the approval email, displays the name and approver of dashboards selected in our Qlik Dashboard Access catalog item. It works fine, but the business has asked for the results to be sorted by approver to make it easier for the approvers to see all the dashboards they are responsible for. Here's my working script without any kind of sort.:
which produces output like this:
Based on this article by Steve Bell, here is m
Image of my attempt that isn't working:
In case anyone is wondering why I am using images instead of pasting code it's because something in the code keeps breaking the form here, sending it into an endless loop where it says an error prevents saving .
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 09:31 AM
ahhhh I see what's going on hahaha
change this section:
var qlikBoards = current.sysapproval.variables.qlik_db.toString();
var db = new GlideRecord('u_qlik_dashboards');
db.addEncodedQuery("sys_idIN"+ qlikBoards );
db.orderBy('u_business_owner');
db.query();
while (db.next()) {
htmlContent += '<tr><td class="table_content" width="45%" align="left">' + db.u_name.getDisplayValue() + '</td><td width="45%" class="table_content" align="left">' + db.u_business_owner.getDisplayValue() +'</td></tr>';
}
this should also improve performance of the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 10:52 AM
To answer your question, it seems to have alphabetized based on the name and not the sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 09:07 AM
I added the line and it still doesn't order it in the export.
Here's the current email script:
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
if(gr.next())
{
gs.log("CDL: From Email " + gr.number + " sys id is "+ gr.sys_id);
}
var attachLink = '<a style="color: blue; text-decoration: underline;" href="' + gs.getProperty("glide.servlet.uri") + gs.generateURL('sc_req_item', gr.sys_id) + '">' + 'Click here' + '</a>';
//Request Item Intro text table
htmlContent = '<table>';
htmlContent += '<tr><td width="100%"><p class="body_content">Hello ' + current.approver.first_name + ',</p>';
htmlContent += '<p class="body_content">' + current.sysapproval.number + ': Qlik Dashboard AccessAcces has been opened to request access to the dashboards listed below for' + current.sysapproval.variables.requested_for.getDisplayValue() +'.</p>';
htmlContent += '<p class="body_content">You are listed as the approver for one or more of the requested dashboards. After reviewing the dashboards you are the approver for listed below, please click either the Approve or Reject link to grant or deny access.</p>';
htmlContent += '<p class="body_content">Thank you.</p></td></tr></table>';
//Dashboard Approver table
htmlContent += '<table id="tlist">';
htmlContent += '<tr><th colspan="2" class="body_content" width="90%">Specific Dashboards Requested</th></tr>';
htmlContent += '<tr><th class="body_content" width="45%">Dashboard Name</th><th class="body_content" width="45%">Access Approved By</th></tr>';
//Build Dashboard Approver rows
var qlikBoards = current.sysapproval.variables.qlik_db.toString();
var list = qlikBoards.split(',');
for (var i = 0; i < list.length; i++) {
var db = new GlideRecord('u_qlik_dashboards');
db.addQuery("sys_id", list[i]);
db.orderBy('u_business_owner');
db.query();
if (db.next()) {
htmlContent += '<tr><td class="table_content" width="45%" align="left">' + db.u_name.getDisplayValue() + '</td><td width="45%" class="table_content" align="left">' + db.u_business_owner.getDisplayValue() +'</td></tr>';
}
}
//Close Dashboard Approver table
htmlContent += '</table>';
//Create & Add link to RITM
htmlContent += '<p></p><p class="body_content">To view more information about the Request Item ' + attachLink + '</p>';
template.print(htmlContent);
which produces this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 09:31 AM
ahhhh I see what's going on hahaha
change this section:
var qlikBoards = current.sysapproval.variables.qlik_db.toString();
var db = new GlideRecord('u_qlik_dashboards');
db.addEncodedQuery("sys_idIN"+ qlikBoards );
db.orderBy('u_business_owner');
db.query();
while (db.next()) {
htmlContent += '<tr><td class="table_content" width="45%" align="left">' + db.u_name.getDisplayValue() + '</td><td width="45%" class="table_content" align="left">' + db.u_business_owner.getDisplayValue() +'</td></tr>';
}
this should also improve performance of the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 10:51 AM