Link to home
Start Free TrialLog in
Avatar of jfsedlar3rd
jfsedlar3rdFlag for United States of America

asked on

Changing Crystal Reports field value programatically.

I am writing an asp.net application and have decided to use the embedded Crystal Reporting solutions canned with VS2005. I store a user id field in the database which i need to display on the report. Our company has AD running where i have code to lookup the user id's and map them to their actual names. Can anyone help  me with updating the user id fields in the report with the names i programatically pull from AD?
Avatar of frodoman
frodoman
Flag of United States of America image

By far the simplest solution is to just add a parameter to your report and position it where you want the user name to display on the report.  When you call the report pass the AD name from your application to the parameter.
SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>> You could also create a formula and change it from the application.  Not sure the .Net version supports that.

That is supported in the .Net version and works just as well.  The only downside is if you're maintaining the report later it isn't obvious that the formula is changed from the application - a parameter always comes from outside and if it's named something like "UsersFullName" it is self-explanatory.
Avatar of jfsedlar3rd

ASKER

I created a stored procedure that pulls the real name from ad with the uid as a parameter, I am not sure what to do with it from this point.
Create a new parameter in your report, then drag the parameter field onto the report design wherever you want the name to appear.  When you call your report from code just pass the real name into the parameter.
Avatar of James0628
James0628

Of course these solutions are, I think, assuming that you only have one user per report.  If you're actually reading data for multiple user id's and want to show the name for each one on the report, I don't think those suggestions will work.  If that's the case, about the only thing that I can suggest is that if you can get the name in a stored procedure, and the report is also using a stored procedure, then maybe you can change the stored procedure that the report is using to pull in the names in the same way.

 James
James0628: i think i am expieriancing the problem as you stated. I have the main report that displays data from a parent table. Then i have a sub report that has a one to many relationship with the parent table,it containing the many. So i cannot created a linked field by placing the uid field that i would like to resolve in the parent report. Is there a way to pass the uid field which resides in the sub report to the parameter of the real name field which executes my Stored Proc to query ad server also resides in the subreport. That way on change of record in  the sub report it would just pass the uid parameter to the stored proc field.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial