Solved

How to get the name of a web user

Posted on 2002-06-10
8
224 Views
Last Modified: 2013-12-18
This is the  code i have written for an agent:
Dim Session As New NotesSession
     Dim db As NotesDatabase
     Dim curdoc As NotesDocument    
     Dim remcreator As NotesItem
     
     Set db=Session.CurrentDatabase
     Set curdoc=Session.DocumentContext
     Set remcreator=curdoc.GetFirstItem("FNRemCreators")
     Set usr=New NotesName(Session.Username)
     remcreator.AppendToTextList(curdoc.remote_user(0))
     Msgbox curdoc.Remote_User(0)
     curdoc.Save True,False

The purpose of this agent is to trap the name of the user who is calling the agent and append the name to the FNremCretors field.
On the Notes client I can do this using Session.UserName but on the browser it returns me the server name.Although I login to the browser using admin but it is unable to trap the value using this code.Any clues???
0
Comment
Question by:sampa
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
Comment Utility
First of all you need to set the agent to run as web user, otherwise the name of the server will be returned.
To do this open the agent properties from the agent list, then on the third tab check the checkmark for "Run Agent as Web user".

To get the name of the currently logged on user, use the EffectiveUserName property of NotesSession.

So in your code this would be:
Set usr=New NotesName(Session.EffectiveUserName)

Regards,
JM
0
 
LVL 10

Accepted Solution

by:
zvonko earned 50 total points
Comment Utility
Hello JM, hello sampa,

Alternatively to setting this option for the agent as upper proposed is there a more simple way getting current web user name: create an additional field on your form and placing a value @Formula to get current logon name of the web user. Do not hide the field with Notes hide-when methods; use http option: “type=hidden” or enable form option: GenerateHtmlForAllFields
One of the suitable value formulas could be: @Name([CN];@UserName)

This method is especially useful if you do not like to loose agent privileges granted from agent signer (saving designer) by using RunAsWebUser option.

Regards,
zvonko

0
 

Author Comment

by:sampa
Comment Utility
Jerrith,thanks for the help but effectiveUserName returns the person who last saved the script but i do not want that I want the person who has currently logged in.I think that way zvonko ur suggestion satisfies the requirement.
Thanks
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
Comment Utility
EffectiveUsername will return the current username if the agent is run as web user.
You have not set the option as I specified, otherwise it would work, without the use of an extra field on the form.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:sampa
Comment Utility
I checked out with everything that u had given but although i had logged in as user1 it was showing me admin and i checked the doc properties it showed modified by admin.
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Thank you for the points :-)

But my buddy JM is right: you surely made a mistake testing his proposal.

Here is my code testing his proposal and getting the described result: effective web user name

Sub Initialize
     Dim Session As New NotesSession
     Dim usr As NotesName
     Set usr=New NotesName(Session.EffectiveUserName)
     Print "Starting...<br>"
     Print "User: " & usr.Common
End Sub

Cheers,
zvonko

PS: you need two print lines on web! Otherwise is a single print line interpreted as redirection URL by Domino web engine.

0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
Comment Utility
It's not the document properties, but the agent properties from the agent list that you need to check.
There is on the design tab of the agent an option you need to check to run an agent as web user.
You need to make sure that the user has sufficient rights to run the agent and perform actions that are performed in the agent for this option to be effective.
I mostly use this option for WebQueryOpen agents where the document is modified and saved when the document is opened from web. (Otherwise you get a save or replication conflict when saving the document afterwards)
0
 

Author Comment

by:sampa
Comment Utility
See actually there is an action called Create Remark which is there on a response doc which has already been created.Once I click on the action I should be able to create a resp to resp doc.Now my purpose is to check whether this user has already created a resp to resp for the current resp doc.If it is so then stop creation of further resp to resp docs.

Jerrith I have checked the same from agent properties.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now