Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 20th, 2021, 06:31 AM
jmerrick0657 jmerrick0657 is offline
Junior Community Member
 
Join Date: Nov 2013
Posts: 38
Default Using custom phone labels from a field in a QR code

I'm trying to allow the user to select the label for a phone number they want to appear in a QR code using a field, however I'm having trouble getting the QR code to use the contents of the field. The entire rule I'm using is below for reference, however the line I'm trying to figure out is :


"TEL;type=Toll Free": Field("TollFree"),


This seems to work fine and displays the label as Toll Free, then the number correctly. However I'm trying to change it to something like this:




"TEL;type=' + Field('C1Label') + '": Field("TollFree"),

With that it is displaying the literal string ' + Field('C1Label') + '


I'm guessing it has to do with using different single / double quotes to delineate what should be interpreted as JavaScript vs displayed as literal text but I can't quite figure it out.


Any help would be appreciated!


-Jake Merrick







Entire rule:
//Function to Make a QR code without truncating font size

function MakeQRBarcodePreciseSize(DataToEncode, ProcessTilde, EncodingMode, ErrorCorrection, PreferredFormat, PointSize, NoFontTag, Font)
{
var encoded = EncodeQRBarcode(DataToEncode, ProcessTilde, EncodingMode, ErrorCorrection, PreferredFormat, PointSize, NoFontTag, Font);

var ReplacedBR = ReplaceSubstring(encoded, "\r\n", "<br>");
var ReplacedSpaces = ReplaceSubstring(ReplacedBR, " ", "");

if (isNaN(PointSize))
return ReplacedSpaces;

var WithPointSize = "<z newsize=\"" + Number(PointSize) + "\">" + ReplacedSpaces;
if (NoFontTag)
return WithPointSize;

var WithFontTag = "<f name=\"" + Font + "\">" + WithPointSize;

return WithFontTag;
}

// vCard 3.0 format
// http://en.wikipedia.org/wiki/vCard

var info = {
N: ToTitleCase(Field("LastName")) + ';' + ToTitleCase(Field("FirstName")) + ';;;;',
FN: ToTitleCase(Field("FirstName")) + ' ' + ToTitleCase(Field("LastName")),
TITLE: ToTitleCase(Field("Title1")),
"TEL;type=Phone": Field("Phone"),
"TEL;type=Toll Free": Field("TollFree"),
EMAIL: ToLower(Field("Email")),
URL: "innovativeos.com",
}

var result = ["BEGIN:VCARD", "VERSION:3.0"];
for (var label in info)
{
if (info[label])
result.push(label + ":" + info[label]);
}
result.push("END:VCARD");

var EncodingMode = "Byte";
var ErrorCorrectionMode = "M";
var PreferredFormat = "0";
//ONLY USE 1 POINT AFTER DECIMAL OR LEADING WILL NOT WORK CORRECTLY
var PointSize = "3.4";
var NoFontTag = false;
var Font = "IDAutomation2D";
var ProcessTilde = false;

// COPYFIT QR CODE //
function CopyfitLineWithMagnifyTag(line, widthInPoints, AllowToExpand)
{
var tm = new FusionProTextMeasure;
tm.CalculateTextExtent(line);
if (tm.messages)
ReportError("CopyfitMagnifyLine: " + tm.messages);

if (tm.textWidth < widthInPoints*100 && !AllowToExpand)
return line;

var factor = Round(widthInPoints / tm.textWidth * 10000, 0) - 1;
return "<magnify type=pointsize factor=" + factor + ">" + line + "</magnify>"; //this horizontally scales type, to proportional scale type change "type=setwidth" to "type=pointsize"
}
var textFrameWidth = FindTextFrame("QRBox").GetSettableTextWidth() / 100; //change "ContactBox" to the name of the text frame

return CopyfitLineWithMagnifyTag(
'<p br=false linespacing=".833333">' + MakeQRBarcodePreciseSize(result.join(Chr(13) + Chr(10)), ProcessTilde,EncodingMode, ErrorCorrectionMode, PreferredFormat,PointSize, NoFontTag, Font), textFrameWidth);
Reply With Quote
  #2  
Old September 27th, 2021, 10:03 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,647
Default Re: Using custom phone labels from a field in a QR code

You can't "compute" a property name in a literal object initializer like that. You have to set that property separately, with its own declaration. I can't test this without your data file, but I think you want to do this, AFTER the closing bracket } for the initializer of the "info" object (right before the line starting with "var result"):
Code:
info["TEL;type=" + Field("C1Label")] = Field("TollFree");
__________________
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
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 01:25 PM.


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