Working with JavaScript in MarkLogic’s Office plugins

Author: Dave Cassel  |  Category: Software Development

MarkLogic Server (MLS) has some pretty cool plug-ins to help you work with Microsoft Office. After you configure and install the plugin, you can now have a side panel in PowerPoint populated by one of your web apps. Here’s an example of how I’ve seen this used: you’re doing some research using a MarkLogic-based search application accessed through your browser. Your project allows you to gather information into a project so you can keep the good stuff together. To finish your work, you need to produce a PowerPoint slide deck. So you use the plugin to open the project where you gathered your information right there within a PowerPoint panel. Click on some project content and it’s injected into the current slide. Pretty nifty.

The power of this capability is that the window where you are presenting content from MLS is actually a little browser window. I admit I’d be happier if they’d used WebKit or Gecko, but oddly enough, Microsoft went with Internet Explorer. Okay, well at least we have the capabilities of a browser inside of Office products, which means we can layout dynamically generated content, use AJAX, and so on.

Here’s where I kept running into trouble: I’d make a change to the JavaScript file that was getting loaded into the panel, but the changes wouldn’t show up. Grr. It turns out that the browser window was helpfully caching that JavaScript file so that it wouldn’t have to reload. As a user, this is a good thing. As a developer, it’s a real pain. How do you tell PowerPoint to reload a JavaScript file or to empty its cache? You won’t find that in the menus.

The Solution

[Update: check Pete’s comment below for a simpler solution.]

Here’s where it comes in handy that Microsoft has tied IE, Office and who knows what else so closely together — the solution turned out to be telling Internet Explorer to clear its cache. Doing so also clears the cache for the browser panel in PowerPoint, which is, after all, just an embedded Internet Explorer window.

One last thing: make sure you close PowerPoint before you clear IE’s cache, otherwise PowerPoint will hang onto the files it’s looking at.

Tags: , ,

2 Responses to “Working with JavaScript in MarkLogic’s Office plugins”

  1. Pete Aven Says:

    Hi David,

    Great post! Here’s a pro tip, you can avoid clearing IE’s cache by just renaming the .js file. Try something like:

    <script type=”text/javascript” src=”blahblah.js?{xdmp:random()}”>//</script>

    You’ll still need to restart the Office application you’re developing in, but won’t have to deal with clearing IE’s cache each time.

  2. Dave Cassel Says:

    Hey Pete… I’ve used an approach like that to avoid caching before, but did it like src=”blahblah.js.r{$release}”, which required a rewriter to strip it off. Your approach is simpler.

Leave a Reply