This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 25, 2011, 4:21 PM
5 Posts

Passing Variables to SSJS

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: sessionScope SSJS Variable
  • Replies: 4
Hi All,

I have a script that works perfectly to take the contents of a view and pass it to Microsoft Excel via a web-client. However, I want the end-user to be able to pass a variable that will limit the results that are returned in the excel spreadsheet.

This works great if I hardcode the variable, but does not bring anything back if I try to use a sessionScope variable I set. Any ideas? Here is the code below...and thanks:


var exCon = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();
var projects:NotesView = database.getView('rptCourseEnrolments')
var viewNav:NotesViewNavigator = projects.createViewNav();
var viewEnt:NotesViewEntry = viewNav.getFirst();
var output:string = "";
while (viewEnt != null)
{

// This is the variable to pass....that is not working
if (viewEnt.getColumnValues().firstElement() == sessionScope.ReportCourseID)
{
output += "<tr>";
for (var x in viewEnt.getColumnValues())
{
output += "<td>" + x + "</td>"
}
output += "</tr>";
}
else
{
output += "<tr>";
for (var x in viewEnt.getColumnValues())
{
output += "<td>" + x + "</td>"
}
output += "</tr>";
}
viewEnt = viewNav.getNext(viewEnt);
}
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment; filename=CourseEnrolments.xls")
// response.setHeader("Cache-Control", "no-cache");
writer.write("<table>");
writer.write("<thead><tr>");
writer.write("<td><b>Course ID</b></td>");
writer.write("<td><b>Session ID</b></td>");
writer.write("<td><b>Participant Name</b></td>");
writer.write("<td><b>Participant WIN ID</b></td>");
writer.write("<td><b>Participant Position</b></td>");
writer.write("<td><b>Participant Department</b></td>");
writer.write("<td><b>Participant Region</b></td>");
writer.write("</tr></thead>");
writer.write(output);
writer.write("</table>");
writer.endDocument();
Mar 27, 2011, 3:15 AM
2 Posts
Re: Passing Variables to SSJS
The if {} and the else {} seem to be doing the same thing ?
So from this code, it doesn't matter what the sessionScope variable is.
Mar 28, 2011, 2:17 PM
5 Posts
Re: Passing Variables to SSJS
Yes, at this point the If and the else are doing the same thing so the code will run in general.
 
However, it is still not the issue I am having, I still need to know how to pass client driven variables in.
 
thanks
Mar 29, 2011, 2:49 PM
2 Posts
Re: Passing Variables to SSJS
This might be related, not a solution but something to look into. I'm seeing a similar problem with two users of an app I recently deployed. I think it may be related to some security setting in IE but I've yet to discover which one. The app pops a new window and the sessionScope variables get nulled out. I don't know if your opening an new browser window before writing the excel sheet but if you are that might be the problem.
 
 
Mar 31, 2011, 4:02 PM
5 Posts
Re: Passing Variables to SSJS
thanks for the input. I tried and that does not seem to be it.
 
The problem I believe is that I cannot seem to pass any variables to non-rendered Xpage.
When I try and pass a sessionScope variable, etc. it seems to not take.'
Any ideas?

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal