Recovering changes made to Framework after a crash

Have you ever spent hours working on a model? Perfecting each join, meticulously defining the cardinality of each individual join, fastidiously testing the queries each step of the way, only to have Framework crash on you?

In this screenshot, I’ve spent entire MINUTES building the joins.

this represents hundreds of seconds of my life

Now, because I’m a hotshot developer I know I can get away with not having Auto Save (Project –> Options –> Auto Save) turned on.  I live on the edge, so I also turn off the rows restriction when testing my queries.

Now here I go, testing my joins when suddenly… Disaster!

Framework is frozen and will soon die.

I’ve killed Framework! (After setting up a Cartesian join between two fact tables, and disabling the rows restriction and randomly clicking until Windows thought the process wasn’t responding.) And now, with dread in my heart, I open the model already knowing what I’ll see.

Reopening the model reveals that nothing was saved. Which makes sense, since I didn't save anything.

But there’s some hope! Looking at the folder, there’s an XML file there called “session-log-backup.xml”

Saved!

Under the projects menu there’s a Run Script option.

script player

Clicking that opens a file browser. Let’s select that session-log-backup…

run script

It recorded every action performed on the model. What happens if we run it?

My hide is saved

And clicking on accept…

it didnt remember the display settings

Almost perfect, it recreated all of the joins (including the crazy Cartesian) and the packages. But it didn’t remember that I like the layout as Star, not as Standard. Now instead of spending hours of my life recreating my work, It’ll take me entire SECONDS to get the diagram back as a star.

I’m still not using Auto Save though.

New Site – update your bookmarks!

As you may have already discovered, I have moved domains! Update your links, inform your friends! With WordPress’ help, I was able to migrate all of the email subscribers. Unfortunately the WordPress subscribers were not migrated. I’ll just continue on without them and hope they notice.

As part of the change, I’ll be able to upload a file containing report samples instead of embedding the XML directly into the post. As report XML can be somewhat large, this will make the posts a bit easier to load.

Eventually, some day, I will add a “Samples” page showing examples of some of the work I’ve done for my clients (with their permission of course).

Do you have any comments about the theme? Love it? Hate it? Did I miss anything or is something not working? Have suggestions for changes I can make to the site, or of possible things I could write about? Drop me a line on the contact page.

Automatically looping through charts in Active Reports

This is the first of a series of articles on extending the usability of Active Reports.

Active Reports makes a wonderful addition to the Cognos suite. Locally processed interactivity (my Brio alter ego is shouting, “so what!”; just ignore him) means complex, though predefined, data exploration scenarios can be offered to ever more demanding users. Just by clicking on a row in a list, the entire report can be refreshed instantly. Standard web-based reports are simply incapable of that behavior.

Periodically I get requests for things Active Reports can’t do. For some reason, saying that something is not possible completely renders all of the other features moot. One such request was: “I want an animated chart that will loop through all of the months in the database”. The user wanted a chart that would show 12 months at a time, incrementing one month per second, looping back to the start once it hits the last month.

As a mockup, I built an example chart in a data deck that shows that behavior.
Chart in Data Deck

I stuck a Data Iterator under it. By pressing the next button you can make it look like it’s animated. Sadly, this wasn’t enough. The needed it to be automatic.

Now we can start playing with JavaScript. This presents a few interesting problems, some of which I’m still trying to solve.

Problem 1. Cognos rewrites IDs.
To demonstrate, I create a text item and an HTML item – a div with text inside it:
HTML Item In RS

But when I run it, and examine the HTML:
HTML Item Div ID Changed

That’s interesting! The ID of the div changed from myDiv to v9! This means that any JavaScript written will have to not use getElementById(). There is no guarantee that the div will be v9 tomorrow. Especially if there are data changes in the report. That’s fine though. I could do a getElementsByTagName(‘div’) and loop through them until I find one that has the correct name, or some other attribute I set. It’ll be slow, but better than nothing.

Let’s see what happens if I use JavaScript to count the number of divs. It should be a simple:

<script>alert(document.getElementsByTagName('div').length)</script>

I just add it to the existing HTML item:
script tag

And yet when I run it, I’m not getting the alert. The JS is sound, and if I copy it to the script console in IE Dev Toolbar I get back the expected value. So what is going on?

Unfortunately this is still one of the things that I’m still trying to figure out. My guess is that every element (list, chart, HTML item) is stored in an object and loaded into the page after the page has been loaded as needed. When running a report with a data deck, we can see that the individual cards aren’t loaded until another control references them. This allows the page to be significantly smaller on the first load, and far more responsive than if everything was rendered. Of course, this is just a guess and I could be completely wrong (but that hardly ever happens).

Effectively this means that onload events are out. And predefined functions are out. Everything will have to be inline events on elements hand written with HTML items.

Getting back to the original problems, the user said that he would be okay with a start/stop button. He presses it to start the “animation”, and clicks it again to stop it whenever he wants. This means we can define the function in the onclick event. And once again I’ve turned to my good friend Dan Freundel for help. And once again he turned 20 lines of spaghetti code into 5 lines of pure JS genius.

Since we can’t loop through divs that don’t yet exist, we’ll have to find a way to recreate the action of clicking on the next/previous buttons on the iterator. One way is to set the parameter directly. Any control that uses that param will be effected. Unfortunately, that way requires referencing minified JS functions. If we do it this way, any upgrade or fix pack will kill the report. Instead, I opted to literally click on the next/prev buttons in the loop.

First, the JS:

<button onclick="
  if(!document.runAnim)
  {

runAnim = function(buttonElement)
{
 var intervalTracker, doStuff = function() {
  var iter = buttonElement.previousSibling
  , ibuttons = iter.getElementsByTagName('button');
  if(ibuttons[2].getAttribute('disabled')) {ibuttons[0].setAttribute('disabled',false);ibuttons[0].click();} else {ibuttons[2].click()}
}
 buttonElement.onclick = function()
 {
    if(intervalTracker)
   {
     clearInterval(intervalTracker);
     intervalTracker = false;
   }
   else
   {
     intervalTracker = setInterval(doStuff,1000);
   }
 };
 intervalTracker = setInterval(doStuff,1000);

};}
runAnim(this);
this.value='stop';
" value="Start animation">Start</button>

First this defines the function. Since we can’t use inline HTML functions will have to be defined like this. On the first run, if the runAnim function doesn’t exist, it will create it. Next it will call that function in the scope of the button. That means the setInterval timer will exist only for that button, and it will not interfere with any other timers on the page. As mentioned before, because the IDs get rewritten, it is impossible to easily reference an element on the page. For this, I simply placed the button directly after the iterator. Next, when an iterator is first loaded, it has no value set and you can’t click any of the buttons. But if, somehow, the disabled=true was removed from the First button, clicking it would select the first item in the list.

So we have the script. The timer function is created the first time the button is clicked, that function and all associated variables are invoked in the scope of the button and it immediately starts working.
Loopy Charts

The list on the right acts both as a highlighter for the current row, and as a control to select which month you want to see in the chart.

Update: Some people have reported issues with the previously attached XML. I’ve updated the report with 10.2.2.
AR-JS.txt (765 downloads)