Automated URL generator for Cognos Reports using Cognos Report Studio

Requirement:
Users request to provide all report name with Report URL and possible prompt default selection so that they can embed in their external web page for user publishing in the way they want to organize.

Report Search path that can be obtained from Audit database:
/content/folder[@name=’Samples’]/folder[@name=’Models’]/package[@name=’GO Data Warehouse (analysis)’]/folder[@name=’Report Studio Report Samples’]/report[@name=’Revenue by Year’]

Case I:

When XSS checking is not enabled, below Cognos Proven Practice document can be used to understand how URL is formed:
http://public.dhe.ibm.com/software/dw/dm/cognos/reporting/scripting_techniques/using_urls_in_cognos_8.pdf


Case II:

When XSS checking is enabled for highly secured intranet environments. Below link provides what needs to be done to encode URL to be compatible:-
http://queryvision.com/custom-cognos-url-support-and-cross-site-scripting/


Design:

You can use Cognos to create a report to do the encoding and creating URL.

Step 1: Get Search Path

Using Audit database:

Report list and search path can be restricted by Audit Report and in final query, you can bring
Report Name
Report Search Path
then create multiple transformation to generate final URL.

Using Native SQL for single URL convertor:
select
#promptmany('pURL','')# as URLPath from dummyTable

Using NativeSQL for multiple search paths [already downloaded in excel] :

select
'/content/folder[@name=''Sample Reports'']/folder[@name=''Models'']/folder[@name=''Dashboard'']/report[@name=''Revenue by Year'']' as URLPath
from DummyTable
Union
select
'/content/folder[@name=''Sample Reports'']/folder[@name=''Models'']/folder[@name=''Dashboard'']/report[@name=''Revenue by Month'']' as URLPath
from DummyTable


Please note that escape characters are required to include quotes in this case.

Step 2: Transformation
Once we get search path in URLPath data item, transformations can be applied [ example]

Conversion [if needed for XSS checking enabled scenario] - more conditions based on characters used:
replace([SQL1].[URLPATH],'/','*2f')
replace([Data Item1], '[', '*5b')replace([Data Item2],'@', '*40')replace([Data Item3],'=', '*3d')replace([Data Item4],']','*5d')replace([Data Item5], ' ', '*20')replace([Data Item6], '''','*27')

Report Path:
substring([URLPATH],position('report[@name=', [URLPATH])+14)position(']',
substring([URLPATH],position('report[@name=', [URLPATH])+14)
) -2
replace(substring([ReportStart],1,[ReportEnd]), ' ', '*20')
Final URL:
'http://localhost/cognos/cgi-bin/cognos.cgi?b_action=cognosViewer&ui.action=run&ui.object=XSSSTART' + [Data Item7] + 'XSSEND&ui.name=XSSSTART' || [ReportName] || 'XSSEND&run.outputFormat=HTML&run.prompt=true' + '&cv.header=false&cv.toolbar=false'

This should generate URL and can be used in html item and downloaded in Excel.




Popular posts from this blog

Cognos Excel Text Wrapping Issue - Row Merge and Column Merge

Cognos: How to replace an existing report without breaking links?

How to change package for a report in IBM Cognos Analytics (ICA)?