Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Currentceusername() function

Status
Not open for further replies.

Dross

Programmer
Aug 16, 2001
212
US
Using CR2008

I have many reports using a command and need to send a parameter to the server in the command based on their Active Directory login to filter server side and not client side.

I have a formula on the report called ADLogon which is simply - currentceusername()

In the command I want to set a variable based on the ADlogon formula to only bring data back for that specific user. I thought it would be easy to have a 2nd formula called PassLogon and have it set the @ADLogon = a parameter then have that parameter in Command (@PassLogon - @ADLogon = {?ADLogon}). So it looks like the SQL WHERE clause below. But it doesn't seem to work. Returns a true instead of the logon. The key seems to be setting the parameter to = currentceusrename() any thoughts?


Declare @ADLogon varchar (9)
select @ADLogon = '{?ADLogon}'

Where SH.username = @ADLogon

Does any of this make sense?


 
I entered a message on the SAP support site. Hopefully they have something useful.
 
Formula gets evaluated after parameters. You need to feed the parameter value before the report runs. At least one of the 3rd-party viewers listed at provides that functionality. You basically name a parameter in a special way and the viewer feeds the Windows user id into that parameter.

hth,
- Ido

view, email, export, burst, distribute, and schedule Crystal Reports.
 
Can't use a 3rd party viewer. Enverything is going through Enterprise and InfoView
 
I'm probably missing something here, but couldn't you just use a command like:

select SH.username
From SH
Where SH.username = currentceusername()

Or,

select SH.username
From SH
Where SH.username = {fn currentceusername()}

-LB
 
You need to pass the Crystal function currentceusername to the command. It works correctly with regular table linking and adding it to the report selection, but no way that I can see to pass it to the command to do server side processing.

That is the bridge I can't seem to cross. My thoughts were create a formula called ADLogon and have it just have the function currentceusername

Then create a parameter called ?ADLogon
Create a 2nd formula that will set @ADLogon = ?ADLogon and pass that in the command as a SQL variable. The problem is setting the parameter to the username.
 
I was suggesting that you could use the command as your datasource and reference it directly. If you are working via the CR GUI, then you could also see if currentceusername() is available in the field explorer->SQL expression function list.

-LB
 
Never thought about the SQL expression, never used it so I am not familiar. I will have to look into that. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top