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 October 31st, 2018, 06:59 AM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 59
Default All records not outputting ?

I've got a test data file containing 7 records. When I compose the file I only get one record output. "All" is selected in the compose window. The following text is from the message log (Minus the header info):
Composing record #1, input record 1
Composing record #2, input record 2
Composing record #3, input record 3
Composing record #4, input record 4
Composing record #5, input record 5
Composing record #6, input record 6
Composing record #7, input record 7
Job ended 09:32:19 - 1540992739.
Total Job Time: 1s

I'm not getting any other errors.

fyi. This file uses JavaScript code in the OnRecordStart callback to set the Page outputs and some address fields that may or may not contain an address. On my machine this file also exhibits the Preview jpg not showing, but being correct on output.

Mac 10.13.6
FusionPro® VDP Creator 10.0.26
Acrobat Build: 19.8.20080.306727
Reply With Quote
  #2  
Old October 31st, 2018, 11:27 AM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 91
Default Re: All records not outputting ?

Can you post the files? It's probably some error in your OnRecordStart.
Reply With Quote
  #3  
Old October 31st, 2018, 11:47 AM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 59
Default Re: All records not outputting ?

Sorry for getting this in the JavaScript thread.

Anyway...I know I didn't do this, but all the page usage was was set to "Unused" in the Manage page area...Or maybe I'm just going nuts?

Still have no images on the preview.
Reply With Quote
  #4  
Old October 31st, 2018, 12:16 PM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 59
Default Re: All records not outputting ?

Nope, that's not it either. All that does is have all pages output. Not what I'm looking for either. Scott can I send you this personally? I'd have to strip out Customer data before I'd want to post to a public forum.
Reply With Quote
  #5  
Old October 31st, 2018, 12:30 PM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 59
Default Re: All records not outputting ?

Here is everything I currently have in the OnRecordStart
**Note. I'm seeing some weird spaces in my code previewing on the web page that don't exist

Quote:
//Look to the Javascript Globals settings for the declared variables.

function myReturn(a){
if(a !=""){
a = "\n" + a;
}
return a;
}
function myPh(a){
if(a !=""){
a = "\nP: " + a;
}
return a;
}
function myFax(a){
if(a !=""){
a = "\nF: " + a;
}
return a;
}

if (Field("Pharmacy1")){
pharms.push(Field("Pharmacy1"));
pharmAdd.push(Field("Street1") +myReturn(Field("Suite1")) +"\n"+ Field("City1") +", "+Field("State1") +" "+Field("Zip1") + myPh(Field("Phone1")) + myFax(Field("Fax1")));
}

if (Field("Pharmacy2")){
pharms.push(Field("Pharmacy2"));
pharmAdd.push(Field("Street2") +myReturn(Field("Suite2")) +"\n"+ Field("City2") +", "+Field("State2") +" "+Field("Zip2") + myPh(Field("Phone2")) + myFax(Field("Fax2")));
}

if (Field("Pharmacy3")){
pharms.push(Field("Pharmacy3"));
pharmAdd.push(Field("Street3") +myReturn(Field("Suite3")) +"\n"+ Field("City3") +", "+Field("State3") +" "+Field("Zip3") + myPh(Field("Phone3")) + myFax(Field("Fax3")));
}
//Allows the skipping of data rows that don't contain a Pharmacy and shifts the data forward. eg. All data in group 3 goes to 2 if 2 is empty.
if (pharms[0]){
address1=pharmAdd[0];
pharmacy1 = pharms[0];
}
if (pharms[1]){
address2=pharmAdd[1];
pharmacy2 = pharms[1];
}
if (pharms[2]){
address3=pharmAdd[2];
pharmacy3 = pharms[2];
}

if (pharms.lenght == 1){
FusionPro.Composition.SetBodyPageUsage("One",true) ;
FusionPro.Composition.SetBodyPageUsage("Two",true) ;
FusionPro.Composition.SetBodyPageUsage("Three",fal se);
FusionPro.Composition.SetBodyPageUsage("Four",fals e);
FusionPro.Composition.SetBodyPageUsage("Five",fals e);
FusionPro.Composition.SetBodyPageUsage("Six",false );
}

if (pharms.lenght == 2){
FusionPro.Composition.SetBodyPageUsage("One",false );
FusionPro.Composition.SetBodyPageUsage("Two",false );
FusionPro.Composition.SetBodyPageUsage("Three",tru e);
FusionPro.Composition.SetBodyPageUsage("Four",true );
FusionPro.Composition.SetBodyPageUsage("Five",fals e);
FusionPro.Composition.SetBodyPageUsage("Six",false );
}

if (pharms.lenght == 3){
FusionPro.Composition.SetBodyPageUsage("One",false );
FusionPro.Composition.SetBodyPageUsage("Two",false );
FusionPro.Composition.SetBodyPageUsage("Three",fal se);
FusionPro.Composition.SetBodyPageUsage("Four",fals e);
FusionPro.Composition.SetBodyPageUsage("Five",true );
FusionPro.Composition.SetBodyPageUsage("Six",true) ;
}
/*switch(pharms.length){

case 1: FusionPro.Composition.SetBodyPageUsage("One",true) ;
FusionPro.Composition.SetBodyPageUsage("Two",true) ;
break;
case 2: FusionPro.Composition.SetBodyPageUsage("Three",tru e);
FusionPro.Composition.SetBodyPageUsage("Four",true );
break;
case 3: FusionPro.Composition.SetBodyPageUsage("Five",true );
FusionPro.Composition.SetBodyPageUsage("Six",true) ;
}*/
Reply With Quote
  #6  
Old November 1st, 2018, 10:26 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,320
Default Re: All records not outputting ?

Thanks, posting the code is helpful. It's still hard to completely analyze this by looking through the keyhole of just the JavaScript rule, without having the rest of the job.

That said, I think the root of your problem is this:
Code:
if (pharms.lenght == 1){
You've misspelled the Array "length" property. Changing all those to this will probably help:
Code:
if (pharms.length == 1){
Also, your code with all those FusionPro.Composition.SetBodyPageUsage calls is way more verbose than it needs to be. Your commented-out switch statement is much better. But if you set all those pages to be Unused in the Page Usage dialog (and you don't even need to name them), then I think you can replace it all with this:
Code:
var frontPage = ((pharms.length - 1) * 2) + 1;
FusionPro.Composition.SetBodyPageUsage(frontPage, true );
FusionPro.Composition.SetBodyPageUsage(++frontPage, true);
And anyone who's been on this forum for a while probably won't be surprised when I tell you that the other code, with the three blocks for Pharmacy1, Pharmacy2, and Pharmacy3, can also be reduced with a "for" loop, like so:
Code:
for (var i = 1; i <= 3; i++)
{
    if (Field("Pharmacy" + i)){
        pharms.push(Field("Pharmacy" + i));
        pharmAdd.push(Field("Street" + i) +myReturn(Field("Suite" + i)) +"\n"+ Field("City" + i) +", "+Field("State" + i) +" "+Field("Zip" + i) + myPh(Field("Phone" + i)) + myFax(Field("Fax" + i)));
    }
}
Other code reductions are possible as well.
__________________
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 November 1st, 2018, 12:54 PM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 59
Default Re: All records not outputting ?

I took out the page names and changed my code per your suggestions to
Quote:
//Look to the Javascript Globals settings for the declared variables. var pharmAdd=[], pharms = [], address1, address2, address3, pharmacy1, pharmacy2, pharmacy3;

function myReturn(a){
if(a !=""){
a = "\n" + a;
}
return a;
}
function myPh(a){
if(a !=""){
a = "\nP: " + a;
}
return a;
}
function myFax(a){
if(a !=""){
a = "\nF: " + a;
}
return a;
}


//Assign Pharmacy Names to pharms array and corresponding address to pharmAdd array.
//Allows the skipping of data rows that don't contain a Pharmacy and shifts the data forward. eg. All data in group 3 goes to array 2 if group 2 is empty.
for (var i = 1; i <= 3; i++)
{
if (Field("Pharmacy" + i)){
pharms.push(Field("Pharmacy" + i));
pharmAdd.push(Field("Street" + i) +myReturn(Field("Suite" + i)) +"\n"+ Field("City" + i) +", "+Field("State" + i) +" "+Field("Zip" + i) + myPh(Field("Phone" + i)) + myFax(Field("Fax" + i)));
}
}

if (pharms[0]){
address1=pharmAdd[0];
pharmacy1 = pharms[0];
}
if (pharms[1]){
address2=pharmAdd[1];
pharmacy2 = pharms[1];
}
if (pharms[2]){
address3=pharmAdd[2];
pharmacy3 = pharms[2];
}

var frontPage = ((pharms.length - 1) * 2) + 1;
FusionPro.Composition.SetBodyPageUsage(frontPage, true );
FusionPro.Composition.SetBodyPageUsage(++frontPage , true);
However when I compose it I get the following which again has me baffled??
Quote:
Composing record #1, input record 1
uncaught exception: Error: In SetBodyPageUsage(), invalid page number 9
Composing record #2, input record 2
uncaught exception: Error: In SetBodyPageUsage(), invalid page number 11
Composing record #3, input record 3
uncaught exception: Error: In SetBodyPageUsage(), invalid page number 15
Composing record #4, input record 4
uncaught exception: Error: In SetBodyPageUsage(), invalid page number 19
Composing record #5, input record 5
uncaught exception: Error: In SetBodyPageUsage(), invalid page number 25
Composing record #6, input record 6
uncaught exception: Error: In SetBodyPageUsage(), invalid page number 29
Composing record #7, input record 7
uncaught exception: Error: In SetBodyPageUsage(), invalid page number 31
Composing record #8, input record 8
Job ended 15:40:16 - 1541101216.
Total Job Time:
...and good Lord I looked and that code for two days and didn't see I miss-spelled length...AAAAhHHHHHHHH!!!!!
Reply With Quote
  #8  
Old November 1st, 2018, 12:55 PM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 59
Default Re: All records not outputting ?

Ohh, I have also run the update to FP 10.1.9
Reply With Quote
  #9  
Old November 1st, 2018, 01:01 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,320
Default Re: All records not outputting ?

Quote:
Originally Posted by ThePorge View Post
However when I compose it I get the following which again has me baffled??
So again, without the job files, I kind of have to guess as to the larger context of what's going on. But the pharms array is global, and this code is in OnRecordStart, right? So I think you need to clear your arrays for each record, like so, at the start of the rule:
Code:
pharms = [];
pharmAdd = [];
Quote:
Originally Posted by ThePorge View Post
...and good Lord I looked and that code for two days and didn't see I miss-spelled length...AAAAhHHHHHHHH!!!!!
Sometimes when you're stuck like this, it's good to add some debugging code, just to "sanity check" your logic. Adding a line such as:
Code:
return pharms.lenght;
would probably have led you to find the mistake. And even adding
Code:
return pharms.length;
would have helped to figure out why you were getting those invalid page numbers, because your global array wasn't being cleared between records. I often leave little debugging lines like that in the rule, commented out.
__________________
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)});

Last edited by Dan Korn; November 1st, 2018 at 01:08 PM.. Reason: added note about debugging
Reply With Quote
  #10  
Old November 1st, 2018, 01:25 PM
ThePorge ThePorge is offline
Regular Contributor
 
Join Date: Aug 2011
Location: Georgia
Posts: 59
Default Re: All records not outputting ?

Dan, you were spot on with clearing the array. Thank you so much this is now working fantastic!!!
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 07:13 PM.


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