Michael Roach Posted March 28, 2019 Share Posted March 28, 2019 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? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 28, 2019 Share Posted March 28, 2019 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. Quote Link to comment Share on other sites More sharing options...
Michael Roach Posted March 29, 2019 Author Share Posted March 29, 2019 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.216124.29 Yancey Control.zip Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 29, 2019 Share Posted March 29, 2019 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: 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). Quote Link to comment Share on other sites More sharing options...
Michael Roach Posted April 1, 2019 Author Share Posted April 1, 2019 Thank you, Dan. We will give this a shot. Quote Link to comment Share on other sites More sharing options...
Michael Roach Posted April 2, 2019 Author Share Posted April 2, 2019 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.216124.29 Yancey Control.zip Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted April 2, 2019 Share Posted April 2, 2019 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: 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"); Quote Link to comment Share on other sites More sharing options...
Michael Roach Posted April 3, 2019 Author Share Posted April 3, 2019 This worked like a charm. Thank you very much. It is really appreciated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.