Using the CurrentCEUserName function in a Crystal Report

I have a field called UserName which includes the firstintial last name field from a table called Store.
This matches the CurrentCEUsername from Crystal Resports Server that identifies our users.
The report I am working with is needing a group by store.
The report has to be set up so only the manager of the store sees the data from the his own store.
The tables that are involved are called Store and Users. They are linked by the STORE_ID.
How can I create a group that will match the CurrentCEUsername when the report should only show the the group value for the Store location. Like California Store or New York Store or Florida Store.

How do I make the CurrentCEUserName responsible for supressing a section when there is no relationship in the to the {store_id} other than the link between the tables.
I know where to put it in the Section Expert | Suppress Condition Box but not sure of the formula.
Now there is one manager per store in te near future we will have more than one manager per store how would that change the formula?
Fletcher BurdineTableau Trainer & Consultant Sales Exec.Asked:
Who is Participating?
frodomanConnect With a Mentor Commented:
Hi ruavol2,

>>> How do I make this work if I have no relationship to the store name

The simple answer is that you can't.  In order to make this work you will need to establish this relationship somehow.  You could create a complicated formula in your selection formula e.g.:

  (CurrentCEUserName = 'TCruise' and {Store} = 'California')
  (CurrentCEUserName = 'BGates' and {Store} = 'Washington')

This means that your report changes everytime this relationship changes.  I would recommend creating a table in the database that contains this mapping (e.g.:  TCruise = California, etc.).  You can then add this table to your report - probably as the primary table and join your other tables to it.  Add a filter in your select expert to this table:

  {RelationShipTable.UserName} = CurrentCEUserName

This will restrict the entries in this table to only the appropriate person and the join between this table and the others (join on state or store name or whatever) will insure all of the data from other tables is only for the correct store.  Another advantage is this same structure allows you to let one person view multiple stores.  If there is a manager just add them multiple times to this table:  (BMan = California, BMan = Oregon   <-- That would let Big Man see both states without any changes to your report).


mlmccConnect With a Mentor Commented:
You can try something like this

CurrentCEUserName = {UserNameField}

Fletcher BurdineTableau Trainer & Consultant Sales Exec.Author Commented:
What about if there is a range or several different managers.comming out of a field. I think I got that one it was the second part of that question that was tougher for me.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Fletcher BurdineTableau Trainer & Consultant Sales Exec.Author Commented:
For mlmmc:
My problem is different the client has the username that would match the CurrentCEUserName
what I do not know how to do is they have a store and a maager say
Store Name = Manager FirstIntial Last Name
California     = TCruise
Washington = BGates
Oregon        = BSaxton
Nevada        = FSinatra
What I do not know how to do is realate that to the store. How do I make this work if I have no relationship to the store name which in this case would be California, Washington,Oregon or Nevada.
Do I create a group with some kind of weird formula in it I am wondering if the database will need to be modified in order to make this happen. How do I say this store group equals the (CurrentCEUsername ={myfieldusername}) I do not know what I have to do? Please advise.
Regarding your posted comment ( - be assured it isn't anything personal.  There aren't many people that respond routinely in this forum.  You'll get better response in the "Crystal Reports" forum generally.  

As you noted, mlmcc is by far the most prolific responder and he knows his stuff so speaking for myself, when I see he's responded to a question I generally assume it's under control and move on.  Also, most experts only look at the most recent postings so if a question has gone stale it may be advisable to post a new 25 point question that points to the original with a plea for help - experts that missed the original question will be prompted to go back and look at it.


Glad i could help

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.