Broken Break in FOREACH

Discussions related to ReadyDoc development.
Post Reply
Posts: 13
Joined: Thu Jan 24, 2019 4:58 pm

Broken Break in FOREACH

Post by DanAtMPL » Thu Apr 08, 2021 5:53 pm

Fixing one thing, tends to break another.

My company recently expanded to have offices in several locations. With the new locations, they have slightly-different customized logos, which we would want displayed at the top of all of our custom documents. The first new location is in Wilmington. The Header info just references the "Settlement Agent" contact information, so the only real change would be the icon itself.

I first thought about creating a 2nd Header ReadyBloc with the Wilmington logo, but then I would have to re-code EVERY. SINGLE. DOCUMENT. to check for Wilmington.

So next, I tried to create an IF statement in the header:

Code: Select all

<IF ({{Order.SettlementAgents[1].Address.City}} = "Wilmington")>(Wilmington logo here)<ELSE>(regular logo here)</IF>
This worked to change the logo, but having the 2 icons in the table altered the dimensions and somehow removed the 2nd line of our address for either city.

Finally, I realized I could just use the same IF statement in the header, with the entire table for each city inside. Which worked like a charm! ... for single-page documents. We also have a multi-purpose Affidavit for sellers/borrowers to sign, that uses a FOREACH loop to create one document per person, and at the end of the first person's loop, it adds a break (Section Break/Next Page) and runs the 2nd person's loop. Which still works fine, EXCEPT that it no longer includes the break, and puts the header for the 2nd person's loop IMMEDIATELY after the 1st person's Notary section.

How can I "have my cake and eat it too" so to speak, or more specifically, have my dynamic icon and also include the page break?
TESTING - Wilmington.pdf
RESULTS: shows the correct Wilmington city icon, but no break between
(75.04 KiB) Downloaded 7 times
TESTING - Not Wilmington.pdf
RESULTS: shows the correct Not-Wilmington city icon, but no break between
(89.58 KiB) Downloaded 7 times
My header which checks the city and displays the appropriate table
(84.27 KiB) Downloaded 7 times

Posts: 13
Joined: Thu Jan 24, 2019 4:58 pm

Re: Broken Break in FOREACH

Post by DanAtMPL » Thu Apr 08, 2021 5:55 pm

I guess there's a limit of 3 attachments per post.
My sample trouble code
(19.88 KiB) Downloaded 7 times

Posts: 1116
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC

Re: Broken Break in FOREACH

Post by BobRichards » Mon Apr 12, 2021 10:28 am

Hey Dan,

Here is the information and corrected document from one of our Document specialists. (Thanks, Wayne!)

The Revised doc is attached. Here are the modifications I made:
  • Added a variable (named $Counter) on the first page to keep count of the multiple people as the document cycles through the FOREACH (iteration) coding.
  • IF that counter is greater than 1, then a page break (Section Break not necessary because the footer is the same on each document) will appear before the body of the document.
  • Removed Section Break from end of document (the way this was previously coded, a Section would be inserted after every Person in the FOREACH, even if there is only one.
If you have any further questions, I can forward them to Wayne.
(40 KiB) Downloaded 17 times
Bob Richards, Senior Software Developer, SoftPro

Post Reply