Adding CrossTrack Links to standalone and parent reports

Follow this procedure to add a CrossTrack link to a standalone or parent report.

Procedure

  1. Create a new list report.
  2. From the Query Explorer, open the query.
  3. In the Properties pane under Miscellaneous, set the name to listMain.
  4. From the Page Explorer, select the main report page, and complete the following steps.
    1. Click the Source tab Source icon in the Insertable Objects pane.
    2. Drag the following query items into the List object box:
      • DEFAULT|[DEFAULT_REL]|GRC_OBJECTS|[SOXCONTROL]|[CN_NAME00]
        
      • DEFAULT|[DEFAULT_REL]|GRC_OBJECTS|[SOXCONTROL]|[CN_DESCRIPTION]
        
      • DEFAULT|[DEFAULT_REL]|GRC_OBJECTS|[SOXCONTROL]|ENUMERATION_FIELDS| 
             CLASSIFICATION (ENUMERATION)|[CN_CLASSIFICATION]
        
      • DEFAULT|[DEFAULT_REL]|GRC_OBJECTS|[SOXCONTROL]|ENUMERATION_FIELDS| 
             DESIGN_EFFECTIVENESS (ENUMERATION)|[CN_DESIGN_EFFECTIVENESS]
        
      • DEFAULT|[DEFAULT_REL]|GRC_OBJECTS|[SOXCONTROL]|[CN_DETAIL_PAGE_URL]
  5. Select the [CN_DETAIL_PAGE_URL] column in the report and cut it (not delete it).
  6. To change the list column titles, complete the following steps.
    1. Select each list column title.
    2. In the Properties pane under Text Source, set the Source Type property to Text.
    3. Double-click in the Text property and type in the appropriate title value. Set the headers to the following values:
      • [CN_NAME00] to Control Name.
      • [CN_DESCRIPTION] to Description.
      • [CN_CLASSIFICATION] to Classification.
      • [CN_DESIGN_EFFECTIVENESS] to Design Effectiveness.
  7. Add the following JavaScript to the report:

    Drag an HTML Item to the beginning of the report.

    Double-click the HTML Item and enter the following code:

    <script language="javascript">
    
    function _fixUpLinkTarget() {
          var crossTrackLinks = document.querySelectorAll('a[href^="javascript:crosstrack("]');
          for (var i = 0; i < crossTrackLinks.length; i++) {
              crossTrackLinks[i].target = "";
          }
    }
    _fixUpLinkTarget();
    
    var _crosstrackTargetWindow;
    function _discoverCrosstrackTargetWindow()
    {
        if(!_crosstrackTargetWindow || typeof(_crosstrackTargetWindow)=='undefined')
        {
            var win;
            if(!window.opener || typeof(window.opener)=='undefined')
            {
                win = window.parent;
            }
            else if(!window.opener.opener || typeof(window.opener.opener)=='undefined')
            {
                if(!window.opener.parent || typeof(window.opener.parent)=='undefined')
                {
                    win = window.opener;
                }
                else
                {
                    win = window.opener.parent;
                }
            }
            else
            {
                win = window.opener.opener;
            }
            _crosstrackTargetWindow = win;
        }
    }
    _discoverCrosstrackTargetWindow();
    function _crosstrack(url, targetWin)
    {
        if(!targetWin || typeof(targetWin)=='undefined')
        {
            if(!window.opener || typeof(window.opener)=='undefined')
            {
                targetWin = window.parent;
            }
            else if(!window.opener.opener || typeof(window.opener.opener)=='undefined')
            {
                if(!window.opener.parent || typeof(window.opener.parent)=='undefined')
                {
                    targetWin = window.opener;
                }
                else
                {
                    targetWin = window.opener.parent;
                }
            }
            else
            {
                targetWin = window.opener.opener;
            }
        }
        try {
    	targetWin.location.href=url;
    	targetWin.focus();
         } catch(err)
         {
    	 window.open(url);
         }
    }
    
    function openResourceInNewUI(url) {
        var resourceName;
        var resourceId = url.substring(url.indexOf("fileId=") + 7, url.length);
        var targetOrigin = url.substring(0, url.indexOf("view.resource.do") - 1);
        var resourceNameSpans = document.querySelectorAll('a[href^="javascript:crosstrack(\'' + url + '"] span');
        if (resourceNameSpans && resourceNameSpans.length > 0) {
            resourceName = resourceNameSpans[0].innerText.trim();
        }
        window.top.postMessage(
            {
                "resourceId": resourceId,
                "resourceName": resourceName
            },
            targetOrigin
        );
    }
    
    function crosstrack(url) {
        if (document.cookie.indexOf("op-last-accessed-ui=task-focused") > 0 && url.indexOf("view.resource.do") > 0) {
            openResourceInNewUI(url);
        } else {
            _crosstrack(url, _crosstrackTargetWindow);
        }
    }
    </script>
  8. Click the Toolbox tab Toolbox icon, and then drag a Hyperlink object into the first column of the list report.
  9. From the toolbar, click the Lock icon Lock icon to unlock the template (the icon changes to unlocked).
  10. To make the hyperlink data item a property of the list, complete the following steps.
    1. Select the List object from the main report page.
    2. In the Properties pane under the Data category, click Properties.
    3. Select [CN_DETAIL_PAGE_URL].
    4. Click OK.
  11. To configure the Hyperlink object, complete the following steps.
    1. Click the Hyperlink text in the cells of the Hyperlink object column.
    2. In the Properties pane under the Text Source category, set the Source Type property to Data Item Value and the Data Item Value property to [CN_NAME00].
    3. In the Properties pane under the URL Source category, set the Source Type property to Report Expression.
    4. Click in the Report Expression property and enter the following JavaScript code in the Expression Definition pane:
      if (ReportOutput()="HTML")
      then
      ("javascript:crosstrack('"+ [listMain].[CN_DETAIL_PAGE_URL] + "');")
      else 
      ([listMain].[CN_DETAIL_PAGE_URL])
      
      Note: The items in italics are the values that need to be replaced when you implement this on your system.
    5. Select the column header text in the Hyperlink object.
    6. In the Properties pane under the Text Source category, set the Text property to Control Name.
  12. From the Toolbar, click the Padlock button again to lock the template (the icon changes to locked).
  13. Select the original [CN_NAME00] column (not the hyperlink column) on the report page and then cut it.
  14. Run the report.
    Note: To test the CrossTrack link, the report must be published and run from OpenPages® with Watson™.

Results

When a user clicks the CrossTrack link from a standalone or parent report, the detail page for that object opens in the application window from which the report was launched.