HTML Links

 < Day Day Up > 



One can embed links to web sites based on object values. For example, if an object returns a list of customers and you know the web site address for each customer, a user can click on the customer name in a report to link to each customer's web site.

Caution 

If SQL tests your patience, combing HTML into your SQL may cause you to lose your patience entirely! Pay careful attention to quotes and note that the syntax is different for each database.

About HTML

The basic syntax for a link to a web site is

  • <a> An HTML anchor element

  • Href The hot spot reference where you will provide the web site address or URL. You may display the URL to users or display different text

  • </a> Ends the HTML anchor element

BusinessObjects requires HTML elements to be enclosed in single quotes.

So, say you want to create a simple list of authors that may be visiting your book store:

<a href="www.website.com">Text to display to users </a> <a href="www.jodipicoult.com">Jodi Picoult </a>

In the object, you need to add the single quotes around the HTML elements, the <a> and </a>.

'<a href="http://www.jodipicoult.com">'Jodi Picoult'</a>'

At this point, your object would not parse, because it lacks a table.column. To have BusinessObjects display the results of a column, the data must be concatenated with the HTML statement. Concatenation symbols vary from database to database; MS SQL Server and MS Access use a plus sign (+), whereas Oracle uses two vertical bars (||).

Therefore, your basic HTML syntax for MS Server or MS Access is

'<a href="http://www.website.com">'+TABLE.COLUMN+'</a>' for MS SQL Server  or MS Access

or for Oracle:

'<a href="http://www.website.com">'||TABLE.COLUMN||'</a>' for Oracle 

If you want the website portion of the Select statement also to be dynamic, you can either access a column that provides a web site address or transform data from another column to form a web address. Concatenating HTML commands, with SQL data, with fixed text data can get messy pretty quickly. For all the concatenations to work correctly, you must use the RDMBS CONCAT function, rather than the + or || operators.

The following example is based on an MS Access database in which the web site address is a column in an Author lookup table:

{fn concat({fn concat('<A HREF='+ {fn char(34)}, '+Authors.Website+'+{fn char(34)}+ '>')},{fn concat( Authors.Author, '<A/>')})}

This second example is based on the sample Sales History database in which the web site address is derived from the city column. The web site address consists of three parts:

  1. The prefix, www.

  2. The city name, which comes from the SQL column SH.CUSTOMERS .CUST_CITY.

  3. The end of the web address, .co.uk. Commercial web site addresses in the U.S. end in .com, while web site addresses in the U.K. end in .co.uk. For this object to work in a global deployment, one would need to add a DECODE or CASE function to test the Country as well.

    Concat(concat('<A HREF=' || chr(34), 'www.'||SH.CUSTOMERS.CUST_CITY||'.co.uk' ||  chr(34) || '>'),concat( SH.CUSTOMERS.CUST_CITY , '<A/>'))

In order for BusinessObjects to generate the SQL statement correctly as an HTML link, you must set the Object Format to Read As HTML. Select the object and right-click to bring up the following pop-up menu:

On the Object Format dialog, click the box Read As HTML.

click to expand

When users run a report, the object with the dynamic link to a web site address is displayed as a hyperlink. In the following screen, you also see the correctly formatted web site address that will take you to the web site for the city of Leeds (www.leeds.co.uk):

click to expand



 < Day Day Up > 



Business Objects(c) The Complete Reference
Cisco Field Manual: Catalyst Switch Configuration
ISBN: 72262656
EAN: 2147483647
Year: 2005
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net