Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 28th, 2019, 09:42 AM
Michael Roach Michael Roach is offline
Forum n00b
 
Join Date: Feb 2019
Posts: 7
Default QR Code Composition Error

We recently have started composing QR codes on our products that we mail out daily. We don't have an issue composing the QR code, it comes up just fine. However, during composition (when there is more than 1 record) we get this error for every single record after the 1st one:

uncaught exception: TypeError: c.charCodeAt is not a function

This error never occurred until we added in the QR codes to our files. The rule we used is Text instead of Graphic and we are composing them from URLs out of .xlsx Excel files.

When we are composing files with 2,000+ records at a time this makes it difficult to be able to catch any other errors that might occur since this will pop up 2,000+ times.

Is there a solution to get rid of this error?
Attached Images
File Type: jpg QR Code Error copy.jpg (140.8 KB, 7 views)
Reply With Quote
  #2  
Old March 28th, 2019, 09:49 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,305
Default Re: QR Code Composition Error

A picture may be worth a thousand words, but it's hard to diagnose what's going on by looking just at the error message through a keyhole. The best way to get an answer is to post the collected job, preferably a minimal example which reproduces the problem.
__________________
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 March 29th, 2019, 10:16 AM
Michael Roach Michael Roach is offline
Forum n00b
 
Join Date: Feb 2019
Posts: 7
Default Re: QR Code Composition Error

Here is a collected file of one of our jobs, as well as a map (.jpg) to compose with it.

Let us know your thoughts. Thank you.
Attached Images
File Type: jpg F190430-GRB-1P.jpg (78.7 KB, 4 views)
Attached Files
File Type: zip 216124.29 Yancey Control.zip (6.92 MB, 3 views)
Reply With Quote
  #4  
Old March 29th, 2019, 12:34 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,305
Default Re: QR Code Composition Error

Thanks. I was able to reproduce the problem with your collected job.

After some investigation, I've determined that this is an apparent bug in the JavaScript engine, triggered by the addition of functions to the String.prototype object in the rule "r_formatDoorOpen". I'll have to investigate further exactly why this happens, but the error goes away with the r_formatDoorOpen rule reworked just a bit to not add functions to the String object prototype, like so:
Code:
function reverse(str) {
    var splitext = String(str).split("");
    var revertext = splitext.reverse();
    var reversed = revertext.join("");
    return reversed;
}

/**
 * Parse a string that looks like time and return a date object.
 * @return  Date object on success, false on error.
 */
function customParseTime(str) {
    // trim it and reverse it so that the minutes will always be greedy first:
    var value = reverse(Trim(str));

    // We need to reverse the string to match the minutes in greedy first, then hours
    var timeParts = value.match(/(a|p)?\s*((\d{2})?:?)(\d{1,2})/i);

    // This didnt match something we know
    if (!timeParts) {
        return false;
    }

    // reverse it:
    timeParts = reverse(timeParts);

    // Reverse the internal parts:
    for( var i = 0; i < timeParts.length; i++ ) {
        timeParts[i] = timeParts[i] === undefined ? '' : reverse(timeParts);
    }

    // Parse out the sections:
    var minutes = parseInt(timeParts[1], 10) || 0;
    var hours = parseInt(timeParts[0], 10);
    var afternoon = timeParts[3].toLowerCase() == 'p' ? true : false;

    // If meridian not set, and hours is 12, then assume afternoon.
    afternoon = !timeParts[3] && hours == 12 ? true : afternoon;
    // Anytime the hours are greater than 12, they mean afternoon
    afternoon = hours > 12 ? true : afternoon;
    // Make hours be between 0 and 12:
    hours -= hours > 12 ? 12 : 0;
    // Add 12 if its PM but not noon
    hours += afternoon && hours != 12 ? 12 : 0;
    // Remove 12 for midnight:
    hours -= !afternoon && hours == 12 ? 12 : 0;

    // Check number sanity:
    if( minutes >= 60 || hours >= 24 ) {
        return false;
    }

    // Return a date object with these values set.
    var d = new Date();
    d.setHours(hours);
    d.setMinutes(minutes);
    return d;
}

var time = customParseTime(Rule("r_extdf_Time"));
time.setMinutes(time.getMinutes() - 30);
return FormatDate(time, "h:nn A");
Even though, in this particular case, this does seem to be a bug in the JavaScript engine, and while adding prototypes to built-in JavaScript objects is a somewhat common practice, and is supported by JavaScript, I would caution against doing this in a FusionPro job, as extending an object in one rule can have unexpected side effects in other rules and built-in functions, since they all operate in a shared JavaScript context for the job (composition).
__________________
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 April 1st, 2019, 08:39 AM
Michael Roach Michael Roach is offline
Forum n00b
 
Join Date: Feb 2019
Posts: 7
Default Re: QR Code Composition Error

Thank you, Dan. We will give this a shot.
Reply With Quote
  #6  
Old April 2nd, 2019, 08:52 AM
Michael Roach Michael Roach is offline
Forum n00b
 
Join Date: Feb 2019
Posts: 7
Default Re: QR Code Composition Error

Hello,

After reworking the "r_formatDoorOpen" rule, we were able to get rid of the error. Thank you very much! There is only one small issue left after fixing this.

After reworking the rule the information now comes up as "Event Begins Promptly at 1:00 PM (Registration begins at 12:30 AM)". However, it should say 12:30 PM since registration begins only 30 minutes prior to the event. I double checked everything in the rule and from what I can see we have it set up the same way that was sent to us. Could you give us a fix so we have the correct AM vs PM?

Thank you very much for your time.
Attached Images
File Type: png Screen Shot 2019-04-02 at 8.39.36 AM.png (19.3 KB, 1 views)
Attached Files
File Type: zip 216124.29 Yancey Control.zip (6.92 MB, 1 views)
Reply With Quote
  #7  
Old April 2nd, 2019, 03:20 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,305
Default Re: QR Code Composition Error

Quote:
Originally Posted by Michael Roach View Post
Hello,

After reworking the "r_formatDoorOpen" rule, we were able to get rid of the error. Thank you very much! There is only one small issue left after fixing this.

After reworking the rule the information now comes up as "Event Begins Promptly at 1:00 PM (Registration begins at 12:30 AM)". However, it should say 12:30 PM since registration begins only 30 minutes prior to the event. I double checked everything in the rule and from what I can see we have it set up the same way that was sent to us. Could you give us a fix so we have the correct AM vs PM?

Thank you very much for your time.
Sorry, this should be the correct rule:
Code:
function reverse(str) {
    var splitext = String(str).split("");
    var revertext = splitext.reverse();
    var reversed = revertext.join("");
    return reversed;
}

/**
 * Parse a string that looks like time and return a date object.
 * @return  Date object on success, false on error.
 */
function customParseTime(str) {
    // trim it and reverse it so that the minutes will always be greedy first:
    var value = reverse(Trim(str));

    // We need to reverse the string to match the minutes in greedy first, then hours
    var timeParts = value.match(/(a|p)?\s*((\d{2})?:?)(\d{1,2})/i);

    // This didnt match something we know
    if (!timeParts) {
        return false;
    }

    // reverse it:
    timeParts = timeParts.reverse();
    
    // Reverse the internal parts:
    for( var i = 0; i < timeParts.length; i++ ) {
        timeParts[i] = timeParts[i] === undefined ? '' : reverse(timeParts[i]);
    }

    // Parse out the sections:
    var minutes = parseInt(timeParts[1], 10) || 0;
    var hours = parseInt(timeParts[0], 10);
    var afternoon = timeParts[3].toLowerCase() == 'p' ? true : false;

    // If meridian not set, and hours is 12, then assume afternoon.
    afternoon = !timeParts[3] && hours == 12 ? true : afternoon;
    // Anytime the hours are greater than 12, they mean afternoon
    afternoon = hours > 12 ? true : afternoon;
    // Make hours be between 0 and 12:
    hours -= hours > 12 ? 12 : 0;
    // Add 12 if its PM but not noon
    hours += afternoon && hours != 12 ? 12 : 0;
    // Remove 12 for midnight:
    hours -= !afternoon && hours == 12 ? 12 : 0;

    // Check number sanity:
    if( minutes >= 60 || hours >= 24 ) {
        return false;
    }

    // Return a date object with these values set.
    var d = new Date();
    d.setHours(hours);
    d.setMinutes(minutes);
    return d;
}

var time = customParseTime(Rule("r_extdf_Time"));
time.setMinutes(time.getMinutes() - 30);
return FormatDate(time, "h:nn A");
__________________
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 April 3rd, 2019, 01:49 PM
Michael Roach Michael Roach is offline
Forum n00b
 
Join Date: Feb 2019
Posts: 7
Default Re: QR Code Composition Error

This worked like a charm. Thank you very much. It is really appreciated.
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 11:21 AM.


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