Jump to content

Building table with external data


Talco

Recommended Posts

Working on a statement and I have two major issues (and one minor issue) to overcome.

 

#1 - I have my table being populated with data from an External Data File. the problem is, its only returning the first matching record and not any additional records from the External file. Its like after it reads one record that matches the ID, it jumps to the next ID rather than finding all the matching ID for that record.

 

#2 -When composing the file has to get set up for duplexing, with each record getting one duplexed sheet. Some will have information on both the front and back (assuming I can get my table to import all matching records from the external data file!) But some will only have one page. These will have to have a second blank page added when composing. I tried to pull JS from the forum, but could not get it to work properly, any ideas.

 

For example assume Record #1 is only one page, I need page 2 to be blank. But record #2 might use the overflow page so it won't need the black page added. I hope that make sense.

 

And my minor issue is... My table gets returned and has two extra horizontal rules under the table. I really need those to go away if possible. I don't think I'm calling any borders or rules out to be printed, but do I need to tell them to be 'off' somewhere?

 

I am really under the gun on this project. I have been messing with it for a couple of days now. This is basically my into to JavaScript and my first truly complex FusionPro job set up. It has been driving me crazy, but I think I'm on the right track and hopefully I'm close, just need some help to get over these last couple issues.

 

I have attached the collected job, please let me know if you have any questions or suggestions!

 

Thanks.

TALCO_table.zip

Link to comment
Share on other sites

#1 - Well, the collected job you attached doesn't include the 'TALCO_trans.txt' file which you're opening with ExternalDataFileEx in your OnJobStart rule, and I can't really debug without it.

 

But I think you have the right idea in your "GIFT-TEST" rule: you're iterating through all the records in the external data file to find matches. The problem is that, when you find the first match, you return from the rule (with the "return" statement) instead of letting the rule continue to accumulate more matches into more table rows. I think you want to keep the logic from the example, which has the return statement, as well as the initial tags to set up the table, outside of the "for" loop, like so:

if(FusionPro.inValidation)
   Rule("OnJobStart");

var myTable = '<table columns=5><column width=5800><column width=9500><column width=13800><column width=21000><column width=6550><alignment="left"';
myTable += '<margins = "top:0;bottom:0;left:0;right:0">';
myTable += '<drawbrule = "false">'

var numRecsExtDF = externalDF.recordCount;

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)
{
   if (externalDF.GetFieldValue(recordWalker, 'ConstID') == Field("CONSTID"))
   {
       myTable += '<row><cell>' + NormalizeEntities(externalDF.GetFieldValue(recordWalker, 'SHDATE')) 
       myTable += '<cell>'+ NormalizeEntities(externalDF.GetFieldValue(recordWalker, 'PAY'))
       myTable += '<cell>'+ NormalizeEntities(externalDF.GetFieldValue(recordWalker, 'FUND'))
       myTable += '<cell>'+ NormalizeEntities(externalDF.GetFieldValue(recordWalker, 'COMMENT'))
       myTable += '<cell><p br=false quad=R>' + NormalizeEntities("$"+externalDF.GetFieldValue(recordWalker, 'AMT'))
   }
}

myTable += '</table>';
return myTable;

Again, I didn't test this, because I don't have the data file, but the idea is that you want to accumulate table rows, and then return everything you've accumulated at the end.

 

#2 - Click on text frame where you have the table, and on the Text Frame palette, click "Overflow...", and then change the selection in the "Add pages" drop-down to "In Pairs" and click OK.

 

As for the minor issue about extra rules under the table, that's also hard for me to reproduce or debug without the data file. Try reworking your rule as I suggested above and see if that still happens.

Link to comment
Share on other sites

Thanks for your response. Sorry about the missing file, I thought it would have gotten pulled when I did the collect.

 

I was able to get the table working correctly late in the day yesterday.

 

The underlining issue at the bottom of my table ended up being a simple fix, once I finally figured it out. FP was telling it to underline. There were some underlined elements at the beginning of that text box and for some reason it was adding the underline to the text at the bottom of the text box.

 

I'm still working on the issue of getting the file to print the blank page. The "add pages in pairs" doesn't do exactly what I need. I'm needing every record to end up being two pages, so they can be printed duplex. The pages that overflow are already working correctly. If the page overflows it gives me my two pages. But if the page doesn't overflow, I'm only getting the one page. This causes a problem when duplex printing.

 

I'm trying to modify this code I found in the forum, but haven't got it 100% worked out yet.

 

var PageCount = 3;

function ActivatePageFromField(fieldName, pageName)
{
   var activate = (Field(fieldName) == "Yes");
   FusionPro.Composition.SetBodyPageUsage(pageName, activate)
   if (activate)
       PageCount++;
}

ActivatePageFromField("Name", "MainPage");

if (FusionPro.inValidation)
   return PageCount;

// Add blank pages to get a total multiple of 2:
var numBlanks = (2 - (PageCount % 2)) % 2; // modulus (remainder) operator trick
for (var i = 1; i <= numBlanks; i++)
   FusionPro.Composition.SetBodyPageUsage("Blank" + i, true);�

Link to comment
Share on other sites

Ronnie, how are you sending this file to your RIP? If you're using PPML then each record set will be self-contained. This way, if you set the enitre job to print duplex, for any record that has only one page you'll just get a single sided sheet.

 

We do this every day and it works perfectly.

Link to comment
Share on other sites

Ronnie, how are you sending this file to your RIP?

 

I exported as PPML and the duplexing worked perfect. Thanks jurgmay.

 

But the sections that were underlined are not printing correctly. The underlining is very light and it messed up the spacing!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...