Skip to main content
Inspiring
October 7, 2013
Question

Need a creative Fm solution to reference an external database

  • October 7, 2013
  • 4 replies
  • 6674 views

Hello community,

I have a project which is turning out to be quite a challenage. I'm hoping someone might have an idea of a creative solution. I use Tech Comm Suite 4.

Here's the project. I have field guide which our company maintains in Fm. The content of the book is aligned with a set of specifications. Basically the specification provides guidance about what must be done and the objectives for a myriad of tasks. Our field guide says how those tasks are performed. Here's an example. The specification says that the drain on an air conditioner must be water-tight, with the objective being that the drain does not leak. Our field guide says how to properly install the drain to achieve that specified outcome. My customers that use our field guide are now required to prove and document alignment between the field guide procedures and the corresponding specification.

My first attempt was rather cumbersome and would not easy to maintain. I thought of a table with the field headings in column and the specifiation ID number in another other.  In our field guide we use a tyical heirchy of Chapter/H1/H2/H3. To get all of the field guide headings I created an LOP. I converted that content into a table and added another column for the spec content. I didn't want book updates to replace this content with the updated LOP so I copied the table to a new document. Then I could add the specifications info to the appropriate places in the table. Very tedious.

Recently the organization that maintains these specifications published the entire set online and provided an API allowing GET requests to the database. For each request there are 6 possible request paramaters and 8 possible respons fields. I'm wondering if it's at all possible to use the API in a Fm marker to pull data with a GET request and insert it into the field guide. I don't know know what our publish format would need to be for this to work. PDF, something from RoboHelp? Maybe there's a better method that I'm not thinking of.

Any ideas or suggestions would be greatly appreciated. If you need any more inforamation, or if I'm not completely clear on something just let me know.

Thanks,

Darrel

    This topic has been closed for replies.

    4 replies

    Inspiring
    October 8, 2013

    Thank you everyone for the quick responses. Definitely a lot for me to consider.

    I don't know yet how often this guide will need to be updated. That's why I'm a bit nervous about the author initiated process. There's a potential for a lot of repeated work. We also may need to create regional versions of the guide. However I don't have any experience with Fm scripting and very little with Java, so I don't know if scripting is a better route.

    I saved and ran Russ' HTTP GET request as a script and Fm popped a script alert window. So I'm not sure what the result should have been.

    Here's my first attempt at this script. Java console says "Result: undefined" so I'm sure I'm doing something wrong. Remember I'm a noobie with scripts and Java.

    var conn = new Socket;

    if (conn.open ("http://developer.nrel.gov/api/standard-work-specs/spec/v1.default", "UTF-8")) {

      conn.write ("GET http://developer.nrel.gov/api/standard-work-specs/spec/v1.json?api_key=my-api-key");

      var reply = conn.read(999999);

      alert(reply.substring(0,500));

      conn.close();

    }

    In case your interested the API documentation is at http://developer.nrel.gov/doc/api/standard-work-specs/spec/v1

    The request URL is GET http://developer.nrel.gov/api/standard-work-specs/spec/v1.format?parameters

    I'll keep messing around a bit and see if I can get some data back.

    Thanks again,

    Darrel

    Legend
    October 8, 2013

    Darrel,

    Try the following. I was able to get something back from your server, but I'm not sure if it is quite right yet, maybe a valid api key is required. The alert() function is intended to popup up an alert with the return from the server. You can ignore the "Result: undefined" message in the script editor.

    socketTest();

    function socketTest()

    {

        var conn = new Socket;

        if (conn.open ("www.developer.nrel.gov:80", "UTF-8")) {

            alert("Connection to server was opened.");

            conn.write ("GET http://www.developer.nrel.gov/api/standard-work-specs/spec/v1.json?api_key=my-api-key HTTP/1.0\n\n");

            var reply = conn.read(999999);

            alert(reply.substring(0,1000));

            conn.close();

        }

    Inspiring
    October 8, 2013

    Russ,

    What did you get back from the server? I inserted my API key but still didn't receive anything.

    I'm trying to run this from the script editor, or from the script library within a Fm document. Is that the proper method?

    Wouild it help if I sent you my API key?

    Darrel

    Legend
    October 8, 2013

    I got curious about ExtendScript and looked this up. Indeed, it is blessedly simple to issue an HTTP GET request and retrieve data from the server, once you figure out the correct way to format the address. Here is some code that retrieves the home page from www.weststreetconsulting.com:

    var conn = new Socket;

    if (conn.open ("www.weststreetconsulting.com:80", "UTF-8")) {

      conn.write ("GET http://www.weststreetconsulting.com:80/default.html HTTP/1.0\n\n");

      var reply = conn.read(999999);

      alert(reply.substring(0,500));

      conn.close();

    }

    Assuming a typical RESTful HTTP API, I would think that a call for content from Darrel's database would be very similar. Once you have the content from the server (the variable 'reply' in the sample above), it's just a matter of parsing out what you need and inserting it into your FM document. All very doable and IMHO a very interesting project.

    Some of you are talking about a direct database connection, OBDC, etc... but given that a HTTP front end service has been built, I think that sort of thing can be avoided. All that is required is a standard socket, presumably on the standard port 80.

    Russ

    Arnis Gubins
    Inspiring
    October 8, 2013

    @Russ,

    That's good to know that Extendscript can do this. Unfortuantely there are so many other minor issues with Extendscript, that it wouldn't be my first choice of tools...

    Legend
    October 8, 2013

    Arnis,

    At the risk of getting off topic here, I feel the need to defend ES a bit. Certainly, it is not as mature and robust as the FDK or FrameScript, but my experience with it is increasingly positive. I've managed to engage some rather complex (and useful) processing with it and for the most part, it works very well and as advertised. I think the biggest problem right now is the lack of expertise in the community (and beginner documentation, etc.). With more adoption and acceptance, there will be more help available when you run into a jam. Right now, I get the most help from non-FM ES forums which is great for general ES activity (like sockets), but not so useful when having a problem with FM objects.

    But of course, you should use what works for you. I just think ES is a great interface with huge potential. I'm using it more these days than the FDK.

    Russ

    Bob_Niland
    Community Expert
    Community Expert
    October 8, 2013

    > Any ideas or suggestions ...

    How often does one document need to be updated, and does it need to be automatic?

    If infrequently, and author-initiated update is OK, you have more degrees of freedom.

    Another approach not yet mentioned would be to use FDK to add pull features to Frame. Scripting is apt to be easier.

    We have an API for pulling descriptors for our product and part SKUs.

    We haven't extended Frame to call it, but have extended both spreadsheets we use to do so. The spreadsheets get updated automatically whenever opened. We export PDF* from the sheet, and import that into Frame, so Frame always gets the latest version. The resulting imported object is full-text searchable in the published PDF, but is not tagged text that Frame can use, obviously.

    Where we need Frame to be able to tag or Xref the pulled content, we also have a spreadsheet that creates MIF. Copy all, save as .MIF, open in Frame, paste where needed. The object probably could be made more automatic by using it as a text inset.

    ________

    * We actually further batch convert the PDFs to EPS due to being on FM7.1.

    Arnis Gubins
    Inspiring
    October 8, 2013

    The only two tools that would allow any sort of database pull directly into xisting FM files are either Patternstream or FrameScript, both supplied via Finite Matters (see: http://www.fml.com/ )

    Depending upon the extent and content of the data required, you might also be able to push the content via a standalone application (database query) and use Datazone's Miramo (or Personal Edition) tool (see: http://www.miramo.com/english/overview/overview.html ) to convert the content markup to FM files that can be included into your field guides.

    More details (or samples) of the type of content and how it is used in your guide would be needed to make any more specific comments or recommendations.

    To do the database pulls via FrameScript directly into your existing FM content, I would highly recommend that you contact Rick Quatro via his site at: http://www.frameexpert.com/

    Participating Frequently
    October 8, 2013

    Am I mis-remembering, or wasn't/isn't there an ODBC connection or similar, that can connect a database to FM?

    Regards,

    Peter

    _______________________

    Peter Gold

    KnowHow ProServices

    Legend
    October 8, 2013

    Darrel,

    This sounds like a perfect job for scripting and a good use case for the extensibility features of FM.

    In addition to what Arnis said, I think ExtendScript should also be able to retreive the content and place it into an FM document. I'm just speaking off the top of my head here, but I seem to recall that HTTP requests via JavaScript are fairly simple. If ExtendScript could generate an HTTPRequest object and retrieve the data, it would be conveniently available for direct insertion into an FM document without any third-party tools or intermediate formats.

    Having said that, this is no trivial task. It would require advanced knowledge of FM scripting and JavaScript in general. I would think, though, that it is the only logical way to go if you really want to realize the quality and efficiency that is possible. Given what you've said, I personally wouldn't consider any other way, even if I had to stumble through a learning curve first.

    Russ