Monday, January 4, 2010

session.CurrentUserName in agentURL?OpenAgent

Have you ever tried to print the current user namen the browser by using a lotus script agent with a code say

   print session.currentusername

triggered by a javascript command say,


What do you think will be printed on the browser?

Canonical form of the current user's name..!!!

No you will get the canonical name of the person or the server who has signed the agent

Yes thats true. And it did trouble me in my project. So How do you overcome it.

Scenario 1: put a computed text on the page or the form being displayed on the browser with the formula @username and ensure that it goes into a html field with some ID. You can always get the current user name using that htm field and pass it along with the agent url as a query string as mentioned below


Then in the lotus script agent you can obtain the query string and hence the user name

Scenario2 (The one I encountered):
The page being displayed on the browser is built by an agent you are not allowed to modify the same except for one single place and that is where I have to trigger my agent.

This issue was resolved through the following means.

Create a Page with the name userInfo.xml with content type set to other: text/xml.

  <computed-text> with formula @username

Now trigger a ajax request to this page,
obtain the response,
parse the xml and get the user name.

Now as mentioned in Scenario 1 pass this in the query string and do as necessary

Hope this is help ful

No comments:

Post a Comment