Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Golden Rule No3 No hard coding of URLs

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#GR3 or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/GR3


Golden Rule No3 No hard coding of URLs.What is the Golden Rule? Why follow this Golden Rule? Exceptions to the rule. How do I fix the problem when it occurs?





What is the Golden Rule?

URLs (Universal Resource Locator) such as http://www.notesninjas.com or http://www.adfos.com should not be hardcoded into agents, action buttons etc

Use computed text or use formulas like

 DBName := @Implode(@Explode(@Subset(@DbName;-1);"\\");"/");

or (this newer version does not confuse the @function text formatting colour coding parser)

 DBName := @Implode(@Explode(@Subset(@DbName;-1); @char(92));"/");

and then

 @URLOpen("/" + DBName+"/Agent1?Open&var=all" );

In lotusscript try using:

 print "<img alt=' On Leave' src="int/leave/$File/leave.gif"">"

or use Script_Name or Path_Info from the document context.

Alternative for Release 6 onwards

Use @webdbname

eg in computed text: marked as pass-thru html:

"<a href='/"+@WebDbName+"?opendatabase&login'>"+@DbTitle+"</a>"

 

Another way of opening Database in the browser from Notes which tries to grab the web hostname:


srvr:=@Subset(@DbName;1);

r:=@If(@ClientType="Web";
 @GetHTTPHeader("Host");
 @DbLookup("";srvr:"names.nsf";"($Servers)";@Subset(@DbName;1);"HTTP_HostName"));

s:=@If(@IsError(r) | @Text(r)="";
@DbLookup("";srvr:"names.nsf";"($Servers)";@Subset(@DbName;1);"SMTPFullHostDomain");
r);

"<a href='"+"http://"+@Text(s)+"/"+@WebDbName+"/formorAgent' target='_blank'>here</a>"

 

Why follow this Golden Rule?

If you move the database or your company gets a new domain name or your company merges you will be in trouble.

If you need a new instance or copy of the database then this will make life easier.

If you like to have a development copy of the database for bug fixing or problem solving this will make your life easier.

If the server goes down and you need to move the database to another server temporarily this make your life easier.

Exceptions

I have not seen a valid reason not to do this.

How do I fix this problem?

Search for "http" or "HTTP" or ".com" or whatever the URL that is failing uses.

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
Lotus Notes and Domino 6 Programming Bible by Brian Benz, Rocky Oliver
Covers all the programming techniques, concepts, and languages used with Notes and Domino, as well as the many new features of Domino 6 Thoroughly examines the Notes and Domino role with Java, XML, Web services, and other IBM products and technologies Provides extensive code and examples, many geared to the needs of administrators High-profile authors, known to their audience through conferences and articles Companion Web site shows example applications from the book running on a live Domino server and provides code download.
See at: Amazon.co.uk | Amazon.com |