Dan Soares
Dan Soares

Reputation: 380

XPages - return shortName of user who is logged in

I was looking for a method getShortName() or attribute of UserName that would return the shortName/UserID of someone who has authenticated with the Domino server. Did a search on the forums, StackOverflow and was unable to find any such method except in the Registration Class.

I'll post my alternative solution below, but if anyone has a better solution I would love to hear it.

Thanks,

Dan

Upvotes: 0

Views: 432

Answers (3)

Per Henrik Lausten
Per Henrik Lausten

Reputation: 21709

You can use the formula command @NameLookup() to return items from a person document. Together with session.evaluate() you should be able to use it in XPages.

Try this:

session.evaluate('@NameLookup([EXHAUSTIVE];' + userName + ';"ShortName")');

Disclaimer: not tested at all.

Upvotes: 2

Dwain Wuerfel
Dwain Wuerfel

Reputation: 373

Not sure what version of the NAB has the hidden view called ($NamesFieldLookup), but if I recall it will include the CN=Bugs Bunny/OU=ACME/O=COM in the first sorted column. This would allow you to skip the first step of your code. Other than that not aware of a provided method to get the short name.

Upvotes: 0

Dan Soares
Dan Soares

Reputation: 380

My solution follows:

var userName = @Name("[ABBREVIATE]" ,@UserName());
var shortName = @DbLookup([@DbName()[0],'names.nsf'],'($VIMPeople)',userName,"ShortName");
return shortName;

Upvotes: 0

Related Questions