2 Replies Latest reply: May 15, 2014 10:09 AM by Bill Watson RSS

    Footer Template to "Look Backwards"

    Arjay418 _

      Hello All,

       

      This is my first post, but I've spent enough time on this forum looking for an answer to my question that I already recognize the names of some of the "regulars".  Didn't readily see an answer yet so here goes.

       

      My report contains a detail line revision history section where each new revision is listed below older revisions.  Each revision entry has numerous fields in the report, but for simplicity in the example below, I only included the main one I need to extract, namely "C-TYPE FIELD:".  Importantly, I really only need to extract the last[/U] instance of this field (i.e., from the last[/U] revision).

       

      Example:

       

       

      Begin Detail Revision History Section

       

          Detail Line Revision Entry Revised 3 months ago

              C-TYPE FIELD: AABBCC

       

          Detail Line Revision Entry Revised 2 months ago

              C-TYPE FIELD: DDEEFF

       

          Detail Line Revision Entry Revised 1 month ago

              C-TYPE FIELD: GGHHII

       

      End Detail Revision History Section

       

       

      /CODE

       

       

      As I mentioned, I need to extract only[/U] the last[/U] instance of C-TYPE FIELD:.  In the above sample this, obviously, would be "GGHHII".

       

      This task wouldn't be so hard if each detail line revision entry were always the same number of lines tall in the report.  Of course they are not.  And regardless of how tall the revision entry is, the field I need tends to hang out toward the top of the entry revision line, with other data below it.

       

       

      Begin Detail Revision History Section

       

          Detail Line Revision Entry Revised 3 months ago

              C-TYPE FIELD: AABBCC

       

          Detail Line Revision Entry Revised 2 months ago

              C-TYPE FIELD: DDEEFF

       

          Detail Line Revision Entry Revised 1 month ago

              C-TYPE FIELD: GGHHII

              Extra Field 1:

              Extra Field 2:

              Extra Field 3:

              Extra Field 4:

       

      End Detail Revision History Section

       

      /CODE

       

       

       

      I got around the variability in the number of lines in each revision entry by attaching a footer to the normal detail template, trapping on "End Detail Revision History Section" in the last line of the sample text, and using "C-TYPE FIELD:" as the preceding string (Advanced Tab) for the field I'm extracting.

       

      This works for most[/U] of the revision entries, which tend to be between 5-8 lines tall.  It works because the sample text of the footer is 8 lines tall, meaning that the model should find preceding string "C-TYPE FIELD:" only once in any 8-line section of the report -- always in the last revision entry since it traps on "End Detail" as the last line of the sample text.

       

      However, in rare cases, a single revision entry can be as tall as 25 lines tall.  For those, the "C-TYPE FIELD:" string is out of the reach of the 8-line footer template (since that string tends to hang out toward the top of the revision entry).  Therefore it's not captured by the model.

       

      But then if I expand the sample text in the footer template to 25 lines, the model will find preceding string "C-TYPE FIELD:" twice[/U] on the normal 8-line revision entries (once from the 2-month-old Revision Entry and once from 1-month-old Revision Entry).

       

      In this case, the model will extract data from the 2-month-old Revision Entry, not from the last, most recent Revision Entry.  This action was confirmed by a comment I read in this forum that said "You might have a problem if the preceding string is likely to be used on any other lines in the report ABOVE the one you want. Monarch always picks the first one it comes to and only the first."

       

      So my question is -- is there any way around this action by Monarch?  Ideally I'd like the model to start "looking backwards" from "End Detail Revision History Section" and once it finds the first instance of "C-TYPE FIELD:" (looking backwards) it extracts the data from that field (i.e., GGHHII).

       

      Hope that makes sense and sorry for the length of the post.  I was going for detail and clarity rather than word economy.

       

      --Arjay

        • Footer Template to "Look Backwards"
          Nigel Winton

          Hello Arjay

          Welcome to the forum.

          Have you tried using the 'End Detail Revision History Section' as the Detail Template, and then trapping the C-TYPE FIELD: as an Append Template with the 'GGHHII' as your field. Then use 'Detail Line Revision Entry Revised'  as another Append Template with the '1 Month Ago' as another field. On the example you gave I can get that to work, but it might need a bit of work to get the final result.

           

          Regards

           

          Nigel

          • Footer Template to "Look Backwards"
            Bill Watson

            Hi Arjay

             

            You could try the following (this presumes there is always at least 1 line between each revision section). This pulls in two lines for the detail section (the ctype field and the line below it). The ctype is pulled out as a seperate field. The "notes" field is set to end at end of left justification so it will pick up as many lines as there are entered. The time line is then pulled in as an append field.

             

            The table view is then sorted by the time field ascending order, and filtered to show only the 1st record. Hope this does what you want or at least gives you a starter on the road.

             

            Paste the following code into a blank text file and save it as an xmod. then apply it to your second sample report. If it does what you want try it against your live report.

             

            /CODE