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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 11th, 2017, 03:39 PM
KrazyKarl KrazyKarl is offline
Forum n00b
 
Join Date: Aug 2017
Posts: 5
Default Having Trouble with new table

Hello, I haven't used FP in four years; now I'm back in the fray and feel like I'm more lost than I ever was back then. I'm far from JS fluent, but I can usually look at similar works (like my old files, which I have) and deduce how to get it to do what I want.

I am tasked with creating a price book for client (liquor distributor). I have worked up a table that should repeat from their data. It will eventually have product breaks for wine origins (California, Oregon, etc.) which is included in the data table. I've got some other items in mind as far as alternating shading, etc.

For now, however, I can't get the table to flow past the first line of data. I've been beating my head against this in my spare time for a couple days now, and I know it must be totally obvious what I'm doing wrong- but I'm not seeing it at all. The table generates, line 1 looks just like I want... but no more lines. I have tried different things from different threads on here, and I'm nowhere.

So - sorry for my noob-ness, but any prod in the right direction would be appreciated! I've included the collection; it's Product Table that isn't doing what I need.

I also know that I should be able to apply the different font Open Sans Condensed for all the header cells in one line, but I'm coding that wrong also apparently. The way I have it isn't elegant, but it works...

TIA for all you guys do.

Karl
Attached Files
File Type: zip WWinsidepage.zip (1.50 MB, 20 views)
Reply With Quote
  #2  
Old August 11th, 2017, 04:52 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Having Trouble with new table

Try putting this in your OnRecordStart callback. Then you can get rid of OnJobStart and ProductTable rules.
Code:
var keyField = 'Origin';
FusionPro.Composition.composeThisRecord = FieldChanged(keyField);

var data = new ExternalDataFileEx(PrimaryInputFile(), ',');
var recs = data.FindRecords(keyField, Field(keyField));
var table = new FPTable();
table.AddColumns(5000,8000,4600,3500,4000,4000,3500,4000,15600);

var header = table.AddRow();
header.Type = 'Header';
header.Cells[0].Font = 'Open Sans Condensed';
header.CopyCells(0,1,2,3,4,5,6,7,8);
header.SetContents("Item #", "Product Name", "Vintage", "Size", "Units", "Case $", "Btl $", "Sale $", "Ratings");

for (var rec in recs) {
  // Helper function.
  function ExField(str) { return data.GetFieldValue(recs[rec], str); }
  var row = table.AddRow();
  var content = ["Product ID","Product","Vintage","Size","Case Pack","Case Price","Bottle Price","Sale Price","Notes"].map(ExField);
  row.SetContents.apply(row, content);
}

var productTable = table.MakeTags();

FusionPro.Composition.AddVariable("ProductTable", productTable, true);
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old August 14th, 2017, 10:35 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,361
Default Re: Having Trouble with new table

Step's solution is great, but there's an even simpler one.

In the Data Source Wizard, on the "Data Fields - Flat File" step, check the "Multi-line records" box.



Then select "Origin" from the fields list on the next step.



Then you don't need any callback rules at all, and your ProductTable rule can be this:
Code:
var table = new FPTable();
table.AddColumns(5000,8000,4600,3500,4000,4000,3500,4000,15600);
var header = table.AddRow();
header.Type = 'Header';
header.Cells[0].Font = 'Open Sans Condensed';
header.CopyCells(0,1,2,3,4,5,6,7,8);
header.SetContents("Item #", "Product Name", "Vintage", "Size", "Units", "Case $", "Btl $", "Sale $", "Ratings");

var data = FusionPro.GetMultiLineRecords();
for (var rec = 1; rec <= data.recordCount; rec++)
{
  function ExField(str) { return TaggedTextFromRaw(data.GetFieldValue(rec, str)); }
  var content = ["Product ID","Product","Vintage","Size","Case Pack","Case Price","Bottle Price","Sale Price","Notes"].map(ExField);
  var row = table.AddRow();
  row.SetContents.apply(row, content);
}
return table.MakeTags();
Besides using less JavaScript, the other benefit of using Multi-line records is that the Preview Record Selector will show the same records as in composed output.
Attached Images
File Type: png multi-line.png (5.6 KB, 80 views)
File Type: png multi-line-2.png (5.4 KB, 76 views)
__________________
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
  #4  
Old August 14th, 2017, 03:11 PM
KrazyKarl KrazyKarl is offline
Forum n00b
 
Join Date: Aug 2017
Posts: 5
Default Re: Having Trouble with new table

Thanks to both of you for the help! I had plugged in Step's option this morning, and it was working fine. I tweaked some column widths and was about to post a thanks to him when I saw Dan's option. Finally got a chance to plug that in, and it is giving me an error.
When I compose, it shows "Value for variable ProductTable not found in instance data". I copied and pasted your code over the previous rule, Dan, and reimported the data as multi line as you showed. The only change I made was the column widths to my new measurements - which if those were off it should just push to second lines, not fail the table. I can go back to Step's version, but thought I would mention it to make sure I'm not missing something else?

Thanks again!
Reply With Quote
  #5  
Old August 14th, 2017, 03:19 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,361
Default Re: Having Trouble with new table

Quote:
Originally Posted by KrazyKarl View Post
When I compose, it shows "Value for variable ProductTable not found in instance data". I copied and pasted your code over the previous rule, Dan, and reimported the data as multi line as you showed.
Is the code in a rule named "ProductTable"?
__________________
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
  #6  
Old August 14th, 2017, 03:51 PM
KrazyKarl KrazyKarl is offline
Forum n00b
 
Join Date: Aug 2017
Posts: 5
Default Re: Having Trouble with new table

Quote:
Originally Posted by Dan Korn View Post
Is the code in a rule named "ProductTable"?
Well, no. Sorry. I copied it into the OnRecordStart that I was working on with Step's solution. So I placed it back in a rule called ProductTable and now it shows the value - but I'm back to only having the first row of data appear.

When I compose the first 20, it repeats the error "Failed to find master page <newpage1>
Master page newpage1 not found." for each record. I'm not seeing a call for newpage1 in the rule, though.
Reply With Quote
  #7  
Old August 14th, 2017, 04:10 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,361
Default Re: Having Trouble with new table

Quote:
Originally Posted by KrazyKarl View Post
Well, no. Sorry. I copied it into the OnRecordStart that I was working on with Step's solution.
That's why I wrote this:
Quote:
Originally Posted by Dan Korn View Post
Then you don't need any callback rules at all, and your ProductTable rule can be this:
Quote:
Originally Posted by KrazyKarl View Post
So I placed it back in a rule called ProductTable and now it shows the value - but I'm back to only having the first row of data appear.
Well, it works for me. With the rule I included in my previous post, I get all the rows of data for each "Origin" set in the output table.

Perhaps you didn't copy the rule I posted exactly? Forgive me, but quite frankly, I'm now skeptical that you followed the rest of what I wrote precisely. I also suspect that you have made other changes that I have no way of seeing.
Quote:
Originally Posted by KrazyKarl View Post
When I compose the first 20, it repeats the error "Failed to find master page <newpage1>
Master page newpage1 not found." for each record. I'm not seeing a call for newpage1 in the rule, though.
That sounds like the Overflow page is not being found. Do you still have an Overflow page named "newpage1" in the job? Again, it seems like you changed something else in the job that is unrelated to the changes I enumerated.

I suppose if you want to attach the job in its current form, I could take another look at it.
__________________
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
  #8  
Old August 15th, 2017, 12:00 PM
KrazyKarl KrazyKarl is offline
Forum n00b
 
Join Date: Aug 2017
Posts: 5
Default Re: Having Trouble with new table

Sorry, Dan, I'm not sure what I had done. I'm certainly not trying to cause an issue, and I definitely appreciate the help you guys are providing.

I went back to the file I had uploaded, made the changes you spec'd, and it all flows in. Whatever other change I had made was clearly the issue. So now I have the data flowing in as expected - thanks so much for your assistance.

Now I can get on to the other details on the job layout. Thank you for your help.
Reply With Quote
  #9  
Old August 16th, 2017, 03:56 PM
KrazyKarl KrazyKarl is offline
Forum n00b
 
Join Date: Aug 2017
Posts: 5
Default Re: Having Trouble with new table

Just when you thought it was safe... So the client loved the proofs I came up with from the last edits. That got them thinking though, and now they have some new ideas.
The way the tables were set, I was placing the <Origin> field in the black bar, then listing all of California. When Origin changed, a new page began and the next set began (Oregon, etc.). The client would like to have no page breaks between Origins, so when California ends, the Oregon bar appears and that list starts.
I've played around with this a couple of ways; to my slow mind, I don't see a good way to do that with the Origin bar in a separate box. I can place it as an inline graphic in the text box, but I was thinking about a repeatable component. I have created that template and placed it in a new rule ProductTable2; the Origin bar appears but the table doesn't start composing after.

Finally, they would like the producer (winery, distillery, etc.) appearing as a new column - but only when it changes, so it acts as a divider. The logical way to do this seems to be defining the data file by Producer instead of Origin - but this creates a potential issue with the Origin bar solution.

So I guess I have several questions -
1) How would you suggest running this solution so there are not page breaks between Origins?
2) Can I define by two variables in a multi-line record to utilize the Origin bar but also use the Producer as a variable?
3) Can I put the repeating component in the same box with a table?
4) Most importantly, when will I learn to say no to clients?

Thanks for your advice and expertise. I'm seeing what they want to achieve, but struggling to picture how to create it.
Attached Files
File Type: zip WWinsidepageREPEATABLE8-15.zip (1.83 MB, 10 views)
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 08:20 AM.


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