jmerrick0657 Posted September 20, 2021 Share Posted September 20, 2021 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); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 27, 2021 Share Posted September 27, 2021 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"): info["TEL;type=" + Field("C1Label")] = Field("TollFree"); 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.