Jump to content

Add a suppress rule to a Table


Susan

Recommended Posts

I am using table rules for this document. I've attached a screenshot showing how the bottom "quote" table is printing copy I don't want. I am using fields “Quote” and “Recipient Name_cal”.

 

Can I put a rule within my table rule to suppress the “-Namel” if there is no copy in the “Quote” field.

 

Below is my table rule for the bottom on the screen shot, fields are highlighted in red:

 

if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)

{

Rule("OnJobStart");

}

 

//Get a count of the total number of records in the external data file

numRecsExtDF = externalDF.recordCount;

 

/*=============================================================================

|| Create arrays to hold values that match the CID of the client's record

||=============================================================================*/

var QuoteMatch = [];

var RecipientMatch = [];

 

 

// Step through the external data file and push matches into their respective variables if there is a match

for (var i=1; i <= numRecsExtDF; i++) {

if (externalDF.GetFieldValue(i, 'Fund') == Field("Fund")) {

QuoteMatch.push(TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Quote')));

RecipientMatch.push(TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Recipient Name_cal')));

 

}

}

 

/*=============================================================================

|| Create the table

||=============================================================================*/

new FPTable;

var myTable = new FPTable;

myTable.AddColumns(47000);

 

 

// interate through the length of the arrays (data matches from external data file) and create rows

for (var i = 0; i < QuoteMatch.length; i++)

{

 

 

// TABLE CONTENT FORMATTING

 

var row = myTable.AddRow();

for (var c = 0; c < myTable.Columns.length; c++)

{

 

row.SetContents(QuoteMatch, RecipientMatch);

 

var cell = row.Cells[c];

cell.Font = "Gotham-Book";

cell.PointSize = "10";

cell.TextColor = "Black";

cell.ShadeColor = "Black";

cell.Margins = { Top:20, Bottom:100, Right:20, Left:20};

cell.VAlign = "Left";

cell.HAlign = "Left";

 

// CREATE CONTENT FOR EXTERNAL DATA FILE RECORDS

row.SetContents(QuoteMatch + " –"+'<f name=Gotham-Medium>'+ RecipientMatch);

}

 

}

return myTable.MakeTags();

Link to comment
Share on other sites

You don't really need to suppress table rows where the quote is empty; you need to simply not output them in the first place. Since you're building up an array of quotes, and then outputting all of the items in that array to the table, you can just not put empty quotes into the array, in this part of the code:

// Step through the external data file and push matches into their respective variables if there is a match
for (var i = 1; i <= numRecsExtDF; i++)
{
   if (externalDF.GetFieldValue(i, 'Fund') == Field("Fund"))
   {
       var quote = TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Quote'));
       var recipient = TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Recipient Name_cal'));
       if (quote)
       {
           QuoteMatch.push(quote);
           RecipientMatch.push(recipient);
       }
   }
}

Link to comment
Share on other sites

Is there a reason you're using a table for that layout? It seems to me you could simplify things by just doing this:

return externalDF.FindRecords('Fund', Field("Fund"))
 .map(function(s){
   var quote = TaggedTextFromRaw(externalDF.GetFieldValue(s, 'Quote'));
   var name = TaggedTextFromRaw(externalDF.GetFieldValue(s, 'Recipient Name_cal'));
   return quote ? [quote, '<f name=Gotham-Medium>' + name].filter(function(p) { return RawTextFromTagged(p); }).join(' - ') : '';
 }).filter(String).join('<br>');

 

But if you want to use a table for some reason, this change should give you the results you want:

if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true) {
 Rule("OnJobStart");
}

//Get a count of the total number of records in the external data file
numRecsExtDF = externalDF.recordCount;

/*=============================================================================
|| Create arrays to hold values that match the CID of the client's record
||=============================================================================*/
var QuoteMatch = [];
var RecipientMatch = [];

// Step through the external data file and push matches into their respective variables if there is a match
for (var i=1; i <= numRecsExtDF; i++) {
 if (externalDF.GetFieldValue(i, 'Fund') == Field("Fund")) {
   [color="Red"]if (quote = TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Quote')))
     QuoteMatch.push(quote);
     RecipientMatch.push(TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Recipient Name_cal')));
   }[/color]
 }
}

/*=============================================================================
|| Create the table 
||=============================================================================*/
new FPTable;
var myTable = new FPTable;
myTable.AddColumns(47000);

// interate through the length of the arrays (data matches from external data file) and create rows
for (var i = 0; i < QuoteMatch.length; i++) {
 // TABLE CONTENT FORMATTING
 var row = myTable.AddRow();
 for (var c = 0; c < myTable.Columns.length; c++) {
   var cell = row.Cells[c];
   cell.Font = "Gotham-Book";
   cell.PointSize = "10";
   cell.TextColor = "Black";
   cell.ShadeColor = "Black";
   cell.Margins = { Top:20, Bottom:100, Right:20, Left:20};
   cell.VAlign = "Left";
   cell.HAlign = "Left";
   // CREATE CONTENT FOR EXTERNAL DATA FILE RECORDS
   row.SetContents(QuoteMatch[i] + " –"+'<f name=Gotham-Medium>'+ RecipientMatch[i]);
 }
}
return myTable.MakeTags();

Link to comment
Share on other sites

Thanks for the help.

 

I was able to get the results I needed using your rule (not the table rule) but I was wondering if there is a way I can keep the quotes from breaking when I use an overflow page. I've attached a sample pdf. When I assign "keep with next paragraph" or change widows to 99 it treats the <Quote External Data Rule> as one object and knocks it all over to the next page. Below is the changes I made to your rule.

 

//Create an empty variable that will be populated with a

//string of text that lists the customer's purchases

returnStr = '';

 

//The following if statement will detect if we are currently in preview

//mode or editing this rule (versus composing output). If so, the script

//will manually call the OnJobStart rule so the link to the external

//data file can be established. OnJobStart is called automatically when

//a full composition is run.

if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)

{

Rule("OnJobStart");

}

 

return externalDF.FindRecords('Fund', Field("Fund"))

.map(function(s){

var quote = TaggedTextFromRaw(externalDF.GetFieldValue(s, 'Quote'));

var name = TaggedTextFromRaw(externalDF.GetFieldValue(s, 'Recipient Name_cal'));

return quote ? ['<f name=Gotham-Book>'+ '"' +quote, '<f name=Gotham-Medium>' + name].filter(function(p) { return RawTextFromTagged(p); }).join('" - ') : '';

}).filter(String).join('<br><br>');

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...