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

How to code URL string to handle three deployment environments? 1

Status
Not open for further replies.

HiBoo

Programmer
Jan 11, 2000
88
0
0
CA
I'm using RS2008 R2. I've created a report that has Action:Go to URL expressions. The expressions link to another report detail that render directly to Excel and work just fine.

The issue I'm having is coding the expression to work in all three of our deployment environments. We have a Development, Acceptance and Production deployment environment. The Action expression in Development reads, " When I deploy to Acceptance I have to change the expression to read, " And in Production I have to change the server location again. So far I've at least created a report variable to store the value so it's easy to change before each deployment but I'm soon going to have more reports to maintain and I'd rather have a dynamic solution that doesn't involve any maintenance at all.

Is there anyway I can code the expression so that it becomes "aware" of which environment it's been deployed? Is there a configuration file option that can be used to store a variable for example? I can't seem to find such a solution so I'm hoping that one of you experts can help me out.

Ideally, the solution would involve a config file but I'm not sure that's an option. I've looked into it but can't seem to find out how to do that. If I could I'd create one config file in each of the three environments with an appropriate URL string that can be read into the expression. Another option would be to create an expression or custom code that can determine what environment it's in to decide which URL string to use. I tried custom code thinking I could use System.IO.Directory.GetCurrentDirectory() but that failed because I couldn't reference System.IO. Am I on the right track? How could I resolve this roadblock?

If you have a suggestion or comment on my logic please clue me in to where I've gone wrong or offer a solution.

Any other comments or suggestions would be greatly appreciated.

Thanks in advance.
 
This is a built in variable called Target Sever url

This will change depending on your environment

I would suggest passing this to a piece of customer code to generate your string
Code:
Public Function Get_URL_Base(TSU as string) as string
dim retVal as string

case TSU = "Target Server URL for DEV"
   retVal = "DEV String"
Case TSU = "Target Server URL for ACCEPT"
   retVal = "ACCEPT String"
Case TSU = "Target Server URL for PROD"
   retVal = "PROD String"
Case Else
   retVal = ""

return retVal
End function

Call it using ="start of url" & code.Get_URL_Base(Globals!ReportServerUrl) & "rest of url"

as the expression in the jump to url property

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Thank Geoff but I don't think this will do what I'm looking for. The function requires an argument value. That value is what I'm looking for. I think I understand what the function does but I've already got that functionality by using a report variable. The problem is that I have to update that variable manually prior to deploying to a different environment. I'd have to do the same with this code. I'd have to update the parameter value being passed to the function. Is there a way to dynamically set the value of TSU?
 
TSU is just the value tht is passed to the function

The actual value cmes from the global values collection and is dependant on the sever that you deploy to - it is not soething that you would need to set - it is just pickd up based on the reportserver that renders the report for you

the targetserverURL i something that is automatically set by SRS so does not need to be set by you - you just need to know the values it can return and test them in the code to return your own string dependant on the environment which is inherently linked to the reportserverURL


Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Geoff, I must have had my blinders on yesterday. Thanks for replying again and clueing me into the obvious... at first I didn't recognize , "Globals!ReportServerUrl". With a fresh pair of goggles on this morning I've implemented your solution with 100% success.

I had to modify the code a bit to make it work for me but the foundation was all yours.

Thank you very much.
 
np - happy to help out

the globals collection is a very handy set of information when it comes to multi environment / multi user partitioning

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top