7 Replies Latest reply on Sep 12, 2013 8:23 AM by mark.stuller

    Thinking outside the box (aka Go12 on the iPad)


      I know that FMDevs are good at thinking of inventive, clever solutions. I'm hoping some of you might have one (or more!) for this problem - I'm tapped out!


      I have a Go app for Inspections that needs to generate output at the end of the Inspection. An email, a pdf or actual printed page for the Person/Company being Inspected. Sometimes it's a single 'page', sometimes several. They might have no 'Violations' so no page for those. Sometimes an Enforcement is issued so an additional page(s) for that. Sometimes - depending on the specifics - they get an additional page showing they are 'Certified'. etc. You get the idea, it varies a lot.


      So as you can imagine, much of this data is stored in records in different tables within the solution. Violations in one, Enforcements in another, Cerifications in another etc.


      One output being requested is *a* pdf so that the business being Inspected can have that emailed to them. As you know a single pdf with variable #s of records from disparate tables/contexts can be ummm 'challenging'. Since 'append to pdf' isn't supported on iOS I had to come up with a different solution. So what I initially did was build a (potentially really long) html 'page' that gathered all the needed data and presented it in a long flowing format. Text, tables, yadda, yadda. Lot's of stuff.


      It presented well on the screen (in a webviewer) but output to a pdf sucks. Something about Save as pdf on iOS/FMGo12 when the layout contains a webviewer -- it's just not workable. Today I'm creating multiple emails with each having a pdf attached for every 'Context' that needs to be covered. The business units are pressing me for a more 'elegant' solution.


      So has anyone dealt with similar challenges? have alternete techniques to try? What ideas about what to try even if you haven't solved this type of problem yourself might prove helpful!


      Thanks! Mark

        • 1. Re: Thinking outside the box (aka Go12 on the iPad)

          I had a client with some complex reporting requirements - a financial statement. The statement was broken down into 6 distinct areas; we had different tables, different search criteria, required fields and a few other wrenches tossed into the works. They wanted the statement to print on a single page if possible.


          What I ended up doing was breaking the report into each logical section.


          The script performs the search for section 1, exports the required information to the temporary directory and then imports it into a dummy table. After each import I set a "section" field so that the records get grouped into their respective area on the statement. We do that for each of the different sections - all going into the same dummy table. In some cases we'd be doing additional calculations on the imported data, in some cases not.


          What we ended up with is a simple sub-summary report, sorted by the section field. That, combined with judicious use of conditional formatting and layering fields fields allowed us to effectively turn on or off fields that were needed in each section.


          You could do something similar, building virtual lists instead of the export/import. Gather all of your data, stuff it somewhere (fields, variables) and then find a way to format it nicely for the creation of your PDF.


          If you're using FM12 the ExecuteSQL script step may help you as you can grab data regardless of context.


          Hope that points you in the right direction.

          1 of 1 people found this helpful
          • 2. Re: Thinking outside the box (aka Go12 on the iPad)

            Load the data you need to display to global variables that you can display as merge variables in the printed document. Go to a layout based on a special-purpose single-record table. You can conditionally show or display the different pages as sub-summary parts on that layout by sorting (and not sorting) on the fields necessary to reveal each sub-summary part. The sort fields don't have to be anything meaningful — just something for the sub-summary parts to target.

            1 of 1 people found this helpful
            • 3. Re: Thinking outside the box (aka Go12 on the iPad)

              Good ideas coming! Thank you both.


              David - this does sound familiar! I have done such an export->import into temporary tables and it does the trick albeit somewhat slowly and at somewhat high developer effort. In places I've done this I end up feeling sad (altho admittedly I don't know if I really should!) that there's overhead for record creation/deletion - increasing the file size. But, I might give this a go.


              Jeremy - This seems to take David's idea and helps address the Export->Import slowness and file size issue. A twist (in a good way) on the concept.


              For either of you - or others - I do have the need to present 2 kinds of data in the output that might be tricky with these techniques (easy peasy in HTML); tables and images. Some tables have variable #s of columns, some of which might also like to have advanced cell formatting like conditional headers, cell borders/shading, formatting of the text like centering, bolding etc. You get the idea.


              Any ideas on handling tables with either technique?


              The other challenge is with images. During the Inspection they can take photos of violations. From 1 to n pics of specific problems. With the html that wasn't too bad, export the image and make image hrefs. With David's temp table techique it's doable (I think...!) with container fields and importing those into the temp table's records but would not be workable with Jim's global variable technique (is that right?)


              Any thought's on these challenges?


              Thanks again! Mark


              Message was edited by: mark.stuller Sorry Jermey - I had Jim, 'cause someone named Jim talked to me as I wrote this post!

              • 4. Re: Thinking outside the box (aka Go12 on the iPad)

                Mark, I'm hoping you find the exact right solution because I have a similar project coming up this winter.

                I haven't really started but I had bookmarked this for an ISO FTP client.



                The notion is to create a web page and email the end user the appropriate URL.

                • 5. Re: Thinking outside the box (aka Go12 on the iPad)

                  I'd like to give an update to folks interested in this.


                  I have taken Jeremy's concept pretty far with pretty good success. So far. That is the concept of a single record 'utility' table with global variables (not global fields) to hold and display the data. Constructing those variables from the data then switching to a layout based on the utility table. Sorting to hide/show subsummaries as needed dependent on the contents needing to be displayed. It works pretty well. A bit different and *somewhat* easier than exporting the data from all the various tables the data naturally resides in and then importing back into a single utility table for display.


                  I do have a couple of sticking points yet to be adequately addressed. If people have ideas I'd appreciate them!


                  - I need/want to be able to apply 'extended' formatting to the contents of the global variables. i.e. while you can set font styles like bold and underline, applying paragraph styles is not possible. Say I want to have centered, bolded and size 14 text in a variable's 1st paragraph then switch to left justified, hanging paragraph unbolded size 12 text format for a bulleted list. I can accomplish the bolding and font sizing effectively, but the paragraph formatting isn't possible. My workaround is to create different global variables for each paragraph style needed. Doable but I have dozens (hunderds?) of global variables where I could get by with far fewer if I could control paragraph formatting. Plus the placement and management of all those global variables on the layout is tricky at best!


                  - Tables/cells. There's a variety of tabular data that needs to be presented. Products being recalled for Food Safety violations for example. With Global variables, cell formatting like borders and shading isn't possible (is it?). As a workaround I've created a relationship from that utility table back to the records in the table where those records exist and display them in a really (really) long portal that shrinks-to-fit. That's in one of the sub-summaries so it appear/disappears as needed. Of course you all immediately noted that the 200 row portal that shrinks if they only have 3 rows is ok...until they have 201!


                  So these two items are the sticking points I've found and worked around semi-successfully so far. Any ideas or thoughts are seriously welcome. Thanks and I hope this has helped others.



                  • 6. Re: Thinking outside the box (aka Go12 on the iPad)

                    HTML, Mark...


                    Everything you want to achieve can be layed out using CSS and html tables...


                    - Lyndsay

                    • 7. Re: Thinking outside the box (aka Go12 on the iPad)

                      Thanks Lyndsay. Been there already tho.


                      I tried that first in fact, as it would allow for exactly the control I need.


                      Printing a webviewer or outputting a webviewer layout on iOS unfortunately doesn't work out. iOS webviewers are fine for *display* but the output quality is horrible. Now if I could render global variables that contained html directly on the layout....that'd be cool!