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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a parameter field read a URL parameter?

Status
Not open for further replies.

ericb1

Programmer
Oct 22, 2004
175
US
Not sure if this can be done in Crystal10, I've read a bunch of posts about dynamic parameters, but this is slightly different I think.

All I'm trying to do is set up a report parameter and have it get it's value from the URL of the report.

So if my report has a parameter called "user" and the report is launched like this from a browser:


Then in my report, Crystal sets the parameter "user" to "ericb". This way I can automatically filter on this user and not show other stuff they're not supposed to see.

Any help is greatly appreciated, thanks!
 
I'm not sure this helps, but with some datasources, a function {fn user()} is available as a SQL expression. You could potentially set this equal to table fields in your record selection formula.

-LB
 
Hi,
Look at the docs on the promptex- url command line option..In your example it would be ( assuming a parameter named user)
Code:
[URL unfurl="true"]http://server/crystal/enterprise10/viewrpt.cwr?id=467&promptex-user=ericb[/URL]
Of course, the selection criteria in the report would have to use this parameter's value to filter the data..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks TB! That's awesome!

Follow-up question: Since I'm using "userID" to filter on, how can I put the user's full name on the report? My brain stopped working today.

It's a formula, but I can't get it quite right:

MainUserTable.FirstName & " " & MainUserTable.Last Name
Where {?user} = MainUserTable.userID

any help is appreciated, thanks!
 
Hi,
To get data from another, unlinked table,
( and I assume that the name table is not the same as the table used in the report for the rest of the data)
you would need a subreport - this may not be practical if all you want is the name.

If the UserID exists in both tables, then just link them by that and create the name formula as usual.

MainUserTable.FirstName & " " & MainUserTable.Last Name







[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I think I'm missing something here. It's all the same table.

The table has the first name, last name, and userID. The userID is matched from the URL to the Crystal parameter.

So I can drag the parameter {?user} onto the stage and see it. But to make it more professional, I want to put the full name instead of the username.

So where table1.userID = {?user} show table1.FirstName & " " & table1.LastName

This is what I'm missing. I can drag the fields onto the stage, but they don't show anything.
 
Hi,
Maybe I was not clear..Do the records returned when the data is filtered by the UserID contain more that that UserID's Name information..If not, then just create a formula:
Code:
@FullName
Trim(table1.FirstName) & " " & Trim(table1.LastName)

If there are more names than just the UserId's name,it will be more complicated.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks yes, there are more than just the UserID's names. The report is everyone that reports to {?user}, so it's them, and anyone reporting to them.

Perhaps I should just go with the userID on the report? I was thinking there was an easy way to select the first & last names from the table and put them together, matched by the parameter {?user} on their userID's.

Thanks again!
 
I discovered another issue, not sure if the "Promptex-URL" was intended for what I'm doing:

I using ASP to launch the reports, into a new window with no adress bar, so the user can't see where they're going. Before I launch the report, I grab their user name from the browser, and add it to the string, but they don't know their user name has been added:
The report is a report that displays employee phone logs for users, so this method filters out everyone except the employees that report directly to the promptex-user, so that managers can run phone log reports on their own, they don't need me to do it, and I thought I found a clever way to make only 1 report instead of having to hard-code many reports for each manager.

The report works fine, grabbing the user from the URL and filtering the report, but when the user uses the "refresh" lightning bolt in the viewer to refresh the report, it doesn't grab the parameter from the URL, it prompts the user for parameter "user". It's only a matter of time beore someone realizes they can then put in another managers username and see phone call logs their not supposed to see.

Is there a way to 1) either force this prompt to be re-read from the URL, or even easier to disable the refresh option in the report, so the user has to close and re-launch the report?

Thanks!
 
Hi,
The Refresh button is one of my least favorite things with parameter-driven reports...

I think there is a configuration page for the ActiveX viewer somewhere in Crystal's labyrinthine page structure that can be modified to eliminate that darned lightening bolt..I know you can with the newer DHTML viewers, it is a property of the viewer object..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Ouch! I'm obviously in a bad situation here then. I have the entire report/web intranet structure already set up, using the same viewer/report setup, just passing in a different reportID each time. And my users actually love the refresh "lightening bolt" to reload date parameters mostly. So I can't disable the refresh for the viewer.

But I was going to use this to filter out employees from seeing sensitive data, and obviously this is not a fail-proof method for doing so.

Is there a way to pass a URL parameter to disable the refresh for just that 1 session? Something like "...promptex-user=eric&refresh=no..." so I could disable the refresh for just this report?

 
Found it (for those who are interested). The URL command of "PromptOnRefresh" which takes a 0 or 1 as a value will not prompt the user for new values. So they'll have to close the browser window and re-open it, thus preventing them from entering someone else's userID.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top