cancel
Showing results for 
Search instead for 
Did you mean: 

need to print Current user Name in crystal report in B1

Former Member
0 Kudos

Hi all,

In Crystal reports there are 2 current user fields

CurrentCEUserName

and CurrentCEUserID

I have tried to add these fields to the footer of my reports, but no information comes out.

Is there any way to find out the current user and print their user name on the report?

Users have 2 id's. Where can I find this info and add it to the report.

A) the windows user id if possible

B) the SAP user id

Thanks

Chris

0 Kudos

Try this ...

CREATE PROCEDURE HR_INFO_USR_LOGIN LANGUAGE SQLSCRIPT SQL SECURITY INVOKER AS BEGIN SELECT X."CardCode", Y."PrintBy", Y."Client" FROM DUMMY LEFT JOIN ( SELECT "CardCode" FROM OCRD WHERE LEFT("CardCode",2) = 'CJ' ) X ON 1 = 1 LEFT JOIN ( SELECT XX."UserCode" as "PrintBy", UPPER(XX."WinUsrName") as "Client" FROM M_SESSION_CONTEXT YY INNER JOIN ( select "UserCode" , "WinUsrName", ( select case when "Action" = 'I' then 'OPEN' when "Action" = 'O' then 'CLOSED' end from USR5 r1 where r1."UserCode" = r."UserCode" and r1."Date" = r."Date" and r1."Time" = Max(r."Time") ) "Login Status" ,"Date", "ClientName", Max(r."Time") "Login Time" from USR5 r where "ProcName" = 'SAP Business One.exe' and TO_VARCHAR(r."Date",'YYYY-MM-DD') = TO_VARCHAR(NOW(),'YYYY-MM-DD') group by "UserCode" , "WinUsrName", "Date", "ClientName" having MAX("Time") = Max(r."Time") ) XX ON YY.value = XX."WinUsrName" INNER JOIN OUSR USR ON XX."UserCode" = USR."USER_CODE" WHERE connection_id=current_connection AND KEY ='APPLICATION_OS_USER' ) Y ON 1 = 1; END

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member

Hi Chris,

If you are using a CR Layout, please add a parameter of UserCode@ to get the log on user.

Thanks

Xianlong Min

tony_matar2
Explorer
0 Kudos

i dont know if you have fixed it but you can create a parameter with the name PrintByUserName@.

include this parameter in the report and then you will get printer by sap username.

former_member206488
Active Contributor
0 Kudos

HI,

If you want SAP user id ,add OUSR table and pick user id from that table.

or check http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14295

Thanks,

Neetu

lovinodo
Explorer
0 Kudos

Hi,

from the guide 'How to Work with Crystal Reports in SAP Business One':

"The UserCode@ parameter is an optional token that is recommended for inclusion only in Crystal Reports layouts where you want to display the currently logged on SAP Business One user code, such as u201Cmanageru201D. The parameter type is String. This token is only for layouts; you cannot use it in reports."

Regards,

Domenico

Former Member
0 Kudos

Thanks Domenico,

This just says that I can't do it as I can't make the reports layouts.

Chris

Former Member
0 Kudos

Hi Chris.......

That would be better if you include the user code and its name under same Command.

Or you may join one more table as OUSR for getting the User Name and ID to be displayed on CR......

Regards,

Rahul

Former Member
0 Kudos

Thanks Rahul,

While I can see the table OUSR has all the user info how do I find out which user is logged in and is printing the report?

Chris