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



Jun 17, 2011, 7:20 PM
3 Posts
topic has been resolvedResolved

SSJS and CSJS and Scope variables and View Columns

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 2
Hello,
 
I have been fighting a problem, but have yet to find a solution searching the forums.   Maybe I am going about this the wrong way, so please let me know.
 
My chanllenge is doing what the Queryopendocument event does in a Notes Client view in an xpage view panel. I need to open a web page using a link created by looking up some config docs in the backend from two fields from the doc in the view.
 
Here is what I got so far,
I need to set two variables when I click on a link in a view column in the ssjs box I have the following

applicationScope.put("orgNumber",arlist.getColumnValue("tx_orgid"));

applicationScope.put("invoiceNumber",arlist.getColumnValue("tx_trxnumber"));

This works, but how can this be done with client side javascript? 
 
Here is the rest, Once I set these scope vars, I run a ssjs function to return a full http address, this works, I click the link in the view and I have a button on the page with the following code 

alert("#{javascript:getARInvoiceLink()}")

This returns the proper http address, so far so good, What I ultimately trying to accomplish is when a user click on a column link it opens a new browser window with this address.

window.open("#{javascript:getARInvoiceLink()}");

I am a new to xpages and am struggling,  but I haven't found anything showing me how to set scope vars from csjs. 
 
 
 
Jun 20, 2011, 2:10 PM
25 Posts
Re: SSJS and CSJS and Scope variables and View Columns
 James,
 
If you're using the Extension Library you can use the JSON RPC service ("Remote Service" in the component palette) to do this. But first I would ask if those values change or are specific to a certain user, click or are different between sessions? If so, I would look at using the sessionScope instead, unless it's specific to a click then I would use viewScope. If you have more than one user clicking those links, using the applicationScope those values will be changing for everyone, not just the current user. If I understood your post correctly and these values are coming from a view then I assume these values are specific to the current user. To learn more about the scoped variables see this article http://www-10.lotus.com/ldd/ddwiki.nsf/dx/xpages-scoped-variables.htm.
 
But onto the RPC, this allows you to define a SSJS method that can be called via CSJS. To do this follow the below procedure: 
  1. Put the RPC control on your page or on a top level page so the same RPC is available everywhere
  2. Give it an ID and a usable Service Name - The service name is what will be used to access the RPC via CSJS
  3. Define your methods and any  arguments they may require
Now that you have an RPC on the page with a service name of "myRPC" and let's say a method of "setApplicationScope" and 2 arguments "varName" and "varValue" you can call it from CSJS like:
 
myRPC.setApplicationScope("orgNumber",arlist.getColumnValue("tx_orgid")); 
 
The JSON RPC is a great tool for allowing/facilitating communication with the server via CSJS. 
 
Keith 
Jun 22, 2011, 6:32 PM
3 Posts
Re: SSJS and CSJS and Scope variables and View Columns
Thanks Keith,
 
Yes, the scope variable shoukld not be application, but session.  I found your other entry http://planetlotus.org/profiles/keith-strickland_91450_the-json-rpc-service and this one by Niklas http://planetlotus.org/profiles/openNTF_81647 whjich helped on the setup, but I ran into a problem in the scope variables actually getting set when clicked on the column link, it would save the previous click and so on. It appeared related to no refresh.  Anyway, I am glad to have learned about this cool json rpc tool.
 
After much frustration, my entire issue was I am a new to xpages and it was just a syntax issue on the csjs, so here is the actual code I have in the column for the on click event for csjs. I changed my ssjs function so I could pass the two variables I needed to build the link.
 

var li = "#{javascript:getARInvoiceLink2(arlist.getColumnValue("tx_orgid"),arlist.getColumnValue("tx_trxnumber"))}";

window.open(li);

 

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