Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 28th, 2016, 06:22 PM
Susan Susan is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Maitland, FL
Posts: 62
Default Add a suppress rule to a Table

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.GetFi eldValue(i, 'Quote')));
RecipientMatch.push(TaggedTextFromRaw(externalDF.G etFieldValue(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[i], RecipientMatch[i]);

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();
__________________
FusionPro Creator v10.1.11 / FusionPro Producer / FusionPro Expression 3.2.2 / Mac OSX 10.14.6 / Acrobat Pro DC

Last edited by Susan; July 13th, 2017 at 11:09 AM..
Reply With Quote
  #2  
Old September 29th, 2016, 09:05 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,592
Default Re: Add a suppress rule to a Table

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:
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);
        }
    }
}
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old September 29th, 2016, 09:32 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Add a suppress rule to a Table

Is there a reason you're using a table for that layout? It seems to me you could simplify things by just doing this:
Code:
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:
Code:
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")) {
    if (quote = TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Quote')))
      QuoteMatch.push(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++) {
    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();
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #4  
Old September 29th, 2016, 11:37 AM
Susan Susan is offline
Regular Contributor
 
Join Date: Oct 2008
Location: Maitland, FL
Posts: 62
Default Re: Add a suppress rule to a Table

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>');
__________________
FusionPro Creator v10.1.11 / FusionPro Producer / FusionPro Expression 3.2.2 / Mac OSX 10.14.6 / Acrobat Pro DC

Last edited by Susan; July 13th, 2017 at 11:09 AM..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:03 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.