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 24th, 2018, 10:40 AM
jpmiller jpmiller is offline
Junior Community Member
 
Join Date: Dec 2016
Location: Jacksonville, FL
Posts: 19
Post Compose Record # with field name for box labels

I am looking to make box labels with info from a .csv file. On the same page, display field"name" and field"sequence".
I have attached a PDF that explains what I wish to accomplish.
Any help would be great.
Attached Files
File Type: pdf Label Sheets_FP.pdf (67.6 KB, 10 views)
Reply With Quote
  #2  
Old September 24th, 2018, 12:36 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,327
Default Re: Compose Record # with field name for box labels

It would be easier to offer more specific suggestions if I had the data file, as well as an actual example of multiple records of output (even if it's "dummied up").

But it looks like you're just doing a fairly basic two-sided, two-up stacked imposition. So you would start out with a two-page "one-up" FusionPro PDF template, with two pages, each 5.5x8.5" (half the size of the imposed 11x8.5" sheet). Get that set up to correctly generate non-imposed or "one-up" output. Then you can go into FP Imposer and set up an FPI file with the 5.5x8.5" page size, the 11x8.5" sheet size, a stack repeat of 2500, and a horizontal repeat of 2, and use that for your composition. I'm pretty sure that will generate the imposed output you want.
__________________
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 25th, 2018, 03:58 AM
jpmiller jpmiller is offline
Junior Community Member
 
Join Date: Dec 2016
Location: Jacksonville, FL
Posts: 19
Smile Re: Compose Record # with field name for box labels

Hi Dan,
Attached is a .csv and FP template that I would like to create to generate box labels of printed items.
The box label is to have the first and last record of that template in that box.
I usually just open the .csv document and copy the info from the appropriate record number.
i.e.,(Label 1)
record #1 value of field name "first";
then record #2500 value of field name "first";
i.e.,(Label 2)
record #2501 value of field name "first";
then record #5000 value of field name "first";
and so on. A little tedious, but gets the job done.
I am looking for a way to automate the creation of the box labels.
I hope this is a bit more clear.
I understand if this is not possible as it seems pretty difficult to automate.
Thank you,
Attached Files
File Type: pdf Label Sheets_FP.pdf (57.2 KB, 4 views)

Last edited by Dan Korn; September 26th, 2018 at 01:41 PM.. Reason: Removed data file containing real customer information.
Reply With Quote
  #4  
Old September 26th, 2018, 10:19 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,327
Default Re: Compose Record # with field name for box labels

Quote:
Originally Posted by jpmiller View Post
Attached is a .csv
Sorry, I don't see the attachment. Can you edit the post and try to attach it again?
__________________
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
  #5  
Old September 26th, 2018, 11:34 AM
jpmiller jpmiller is offline
Junior Community Member
 
Join Date: Dec 2016
Location: Jacksonville, FL
Posts: 19
Smile Re: Compose Record # with field name for box labels

I updated the post with the attachments.
Reply With Quote
  #6  
Old September 26th, 2018, 01:41 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,327
Default Re: Compose Record # with field name for box labels

Okay, thanks for posting the data file. I did ask you to do that. But I did NOT expect you to post actual people's data to a public forum such as this. I'm not a lawyer, but even though it's just names and addresses, I suspect that's probably a HIPAA violation (which is ironic since your template says, "HIPAA COMPLIANT"). At the very least, it's not good handling of customer data. So I've removed that data file. You should have a sample data file with dummy data, and you should probably use it for the entirety of your template building and testing. I'm working on your template using the data file from the Cellphone tutorial installed with FusionPro. It only has 650 records, so it's not perfect for testing your batches of 2500 records, but that number of records per box/label can be easily configured in a rule in the job.
__________________
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
  #7  
Old September 26th, 2018, 02:03 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,327
Default Re: Compose Record # with field name for box labels

I think I understand what you're doing now. You're not trying to compose every record in the data file; you just need to denote ranges of the data. This isn't too hard to do, with a little bit of JavaScript.

The attached template does what I think you want, with the data file you posted earlier (since removed), though anyone can try it with the cellphone.txt data file in the FusionPro Tutorials folder, or really any data file, by pointing to that data file in the Data Source Wizard, and modifying the lines at the top of OnRecordStart, which looks like this:
Code:
// For testing with dummy data file cellphone.txt:
//var recordsPerBox = 50;
//var nameFieldName = "Lname";

// For production, with live data "file for box label.csv":
var recordsPerBox = 2500;
var nameFieldName = "first";

var data = new ExternalDataFileEx(PrimaryInputFile());
var totalRecs = data.recordCount;
var numBoxes = Math.ceil(totalRecs / recordsPerBox);
FusionPro.Composition.repeatRecordCount = numBoxes;
var boxNum = FusionPro.Composition.repeatRecordNumber;
var boxStartRec = (boxNum - 1) * recordsPerBox + 1;
var boxEndRec = Math.min(boxNum * recordsPerBox, totalRecs);

FusionPro.Composition.AddVariable("totalRecs", totalRecs);
FusionPro.Composition.AddVariable("boxNum", boxNum);
FusionPro.Composition.AddVariable("numBoxes", numBoxes);
FusionPro.Composition.AddVariable("boxStartRec", boxStartRec);
FusionPro.Composition.AddVariable("boxEndRec", boxEndRec);
FusionPro.Composition.AddVariable("boxStartName", data.GetFieldValue(boxStartRec, nameFieldName));
FusionPro.Composition.AddVariable("boxEndName", data.GetFieldValue(boxEndRec, nameFieldName));
The text boxes in the template use the variables added above. The only other thing the job needs is this in OnJobStart:
Code:
// Don't compose every record.  In OnRecordStart, we'll repeat for the number of box labels we need.
FusionPro.Composition.composeAllRecords = false;
FusionPro.Composition.startRecordNumber = 1;
FusionPro.Composition.endRecordNumber = 1;
With your data file, this outputs 14 pages (labels), where the first shows the names from records 1 and 2500, and the last shows the names from records 32501 and 33843.
Attached Files
File Type: pdf Label Sheets_FP-Dan-1.pdf (58.6 KB, 11 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
  #8  
Old September 27th, 2018, 04:31 AM
jpmiller jpmiller is offline
Junior Community Member
 
Join Date: Dec 2016
Location: Jacksonville, FL
Posts: 19
Default Re: Compose Record # with field name for box labels

Thanks for removing the data file. I wasn't thinking.
Reply With Quote
  #9  
Old September 27th, 2018, 11:21 AM
jpmiller jpmiller is offline
Junior Community Member
 
Join Date: Dec 2016
Location: Jacksonville, FL
Posts: 19
Smile Re: Compose Record # with field name for box labels

Here is the final JavaScript. I duplicated it for each instance I needed and changed the return value accordingly. Had to add var boxStartName and var boxEndName, Also changed OnRecordStart to OnJobStart. Thank you for your help with this! This will be a valuable time saver.

// automation of box label entries
// nameFieldName should be mapped to appropiate field use
var recordsPerBox = 2500;
var nameFieldName = "first";

var data = new ExternalDataFileEx(PrimaryInputFile());
var totalRecs = data.recordCount;
var numBoxes = Math.ceil(totalRecs / recordsPerBox);
FusionPro.Composition.repeatRecordCount = numBoxes;
var boxNum = FusionPro.Composition.repeatRecordNumber;
var boxStartRec = (boxNum - 1) * recordsPerBox + 1;
var boxEndRec = Math.min(boxNum * recordsPerBox, totalRecs);
var boxStartName = (data.GetFieldValue(boxStartRec, nameFieldName));
var boxEndName = (data.GetFieldValue(boxEndRec, nameFieldName));

FusionPro.Composition.AddVariable("totalRecs", totalRecs);
FusionPro.Composition.AddVariable("boxNum", boxNum);
FusionPro.Composition.AddVariable("numBoxes", numBoxes);
FusionPro.Composition.AddVariable("boxStartRec", boxStartRec);
FusionPro.Composition.AddVariable("boxEndRec", boxEndRec);
FusionPro.Composition.AddVariable("boxStartName", data.GetFieldValue(boxStartRec, nameFieldName));
FusionPro.Composition.AddVariable("boxEndName", data.GetFieldValue(boxEndRec, nameFieldName));
return boxEndName;
Reply With Quote
  #10  
Old January 14th, 2019, 09:48 AM
jpmiller jpmiller is offline
Junior Community Member
 
Join Date: Dec 2016
Location: Jacksonville, FL
Posts: 19
Default Re: Compose Record # with field name for box labels

I am trying to rework the math of the rule so that a batch is split in two for boxing purposes with no more than 2,500 per box.


Here is the existing rule.
// I think there needs to be a loop here to determine the current batch quantity

var runBatch = (i !< (cannot be greater than) 5000);

// insert for Loop here to check for i > 5000
// else if runBatch =< 5000

var recordsPerBox = runBatch / 2;

var nameFieldName = "first";

var data = new ExternalDataFileEx(PrimaryInputFile());
var totalRecs = data.recordCount;
var numBoxes = Math.ceil(totalRecs / recordsPerBox);
FusionPro.Composition.repeatRecordCount = numBoxes;
var boxNum = FusionPro.Composition.repeatRecordNumber;
var boxStartRec = (boxNum - 1) * recordsPerBox + 1;
var boxEndRec = Math.min(boxNum * recordsPerBox, totalRecs);



FusionPro.Composition.AddVariable("totalRecs", totalRecs);
FusionPro.Composition.AddVariable("boxNum", boxNum);
FusionPro.Composition.AddVariable("numBoxes", numBoxes);
FusionPro.Composition.AddVariable("boxStartRec", boxStartRec);
FusionPro.Composition.AddVariable("boxEndRec", boxEndRec);
FusionPro.Composition.AddVariable("boxStartName", data.GetFieldValue(boxStartRec, nameFieldName));
FusionPro.Composition.AddVariable("boxEndName", data.GetFieldValue(boxEndRec, nameFieldName));
Attached Files
File Type: pdf VDP Label Sheet_new.pdf (161.9 KB, 4 views)
File Type: zip label test file_more than 5000.csv.zip (32.5 KB, 5 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 06:15 AM.


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