rpaterick Posted March 26, 2013 Share Posted March 26, 2013 Text field for QR Contact Information code: Full Name, Phone, Email, and Address work but I can't get the City, State, and Zip to populate(QR reader on a Iphone5). I tried to manipulate the code for the following fields: City State Zip var NameFieldOrRule = "Full Name"; var PhoneFieldOrRule = "phone 1 number"; var EmailFieldOrRule = "Email Address"; var CityFieldOrRule = "City"; var AddressFieldOrRule = "Address 1"; var StateFieldOrRule = "State"; var ZipFieldOrRule = "Zip"; var PointSize = ""; // MECARD format // http://www.nttdocomo.co.jp/english/service/imode/make/content/barcode/function/application/addressbook // Also see: http://code.google.com/p/zxing/wiki/BarcodeContents var info = { N: FieldOrRule(NameFieldOrRule), TEL: OptionalFieldOrRule(PhoneFieldOrRule).replace(/\D/g,''), EMAIL: OptionalFieldOrRule(EmailFieldOrRule), CITY: OptionalFieldOrRule(CityFieldOrRule), ADR: OptionalFieldOrRule(AddressFieldOrRule), State: OptionalFieldOrRule(StateFieldOrRule), ZIP: OptionalFieldOrRule(ZipFieldOrRule), } var result = ""; for (var label in info) { if (!info[label]) continue; result += label; if (!label.match(/\:$/)) result += ":"; result += info[label]; result += FusionPro.inValidation ? '\r' : ';'; } if (FusionPro.inValidation) return result; var QR = new QRBarcode; QR.pointSize = Int(PointSize) || 6; return QR.Make("MECARD:" + result + ";"); Am I better off changing the QR Contact (vCard) - Graphic? Just wanted to see what direction to head. Thanks! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 26, 2013 Share Posted March 26, 2013 The best thing to do is to find an example of a barcode that does scan successfully on your iPhone. Then, there should be an option in the barcode reader app to give you back the text contents of the barcode verbatim. Once you have that, you can write the rule so that it generates the barcode contents to match that format. Quote Link to comment Share on other sites More sharing options...
rpaterick Posted March 26, 2013 Author Share Posted March 26, 2013 The best thing to do is to find an example of a barcode that does scan successfully on your iPhone. Then, there should be an option in the barcode reader app to give you back the text contents of the barcode verbatim. Once you have that, you can write the rule so that it generates the barcode contents to match that format. It appears the previous print shop put the Address, City, State and Zip all in one column. Is there a way to use the "+" feature for concatenating in the QR code? something like this below.... ADR: OptionalFieldOrRule(AddressFieldOrRule) OptionalFieldOrRule(CityFieldOrRule), + OptionalFieldOrRule(StateFieldOrRule), + OptionalFieldOrRule(ZipFieldOrRule), Thanks Dan! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 26, 2013 Share Posted March 26, 2013 (edited) It appears the previous print shop put the Address, City, State and Zip all in one column. Is there a way to use the "+" feature for concatenating in the QR code? something like this below.... ADR: OptionalFieldOrRule(AddressFieldOrRule) OptionalFieldOrRule(CityFieldOrRule), + OptionalFieldOrRule(StateFieldOrRule), + OptionalFieldOrRule(ZipFieldOrRule),Thanks Dan! Sure, although (1) you don't specify what the field delimiter should be, and (2) your syntax isn't quite right. You need to add some literal delimiter characters in there, using the + (string concatenation) operator. Assuming that the fields within the address should be delimited with commas, as is the convention for MECARD, this will probably work: ADR: OptionalFieldOrRule(AddressFieldOrRule) + "," + OptionalFieldOrRule(CityFieldOrRule) + "," + OptionalFieldOrRule(StateFieldOrRule) + "," + OptionalFieldOrRule(ZipFieldOrRule),Or, it might be easier to do all that on a different line, and assign the full address to another variable, which will make the code a little cleaner. So near the top of the rule, you can do this: var Address = OptionalFieldOrRule(AddressFieldOrRule) + "," + OptionalFieldOrRule(CityFieldOrRule) + "," + OptionalFieldOrRule(StateFieldOrRule) + "," + OptionalFieldOrRule(ZipFieldOrRule);Or, even more succinctly: var Address = [ OptionalFieldOrRule(AddressFieldOrRule), OptionalFieldOrRule(CityFieldOrRule), OptionalFieldOrRule(StateFieldOrRule), OptionalFieldOrRule(ZipFieldOrRule) ].join();Then the line setting the property of the "info" object can be simply: ADR: Address,Also, you could change all of those calls to OptionalFieldOrRule to call FieldOrRule, or even simply Field, instead, since the field names are all specified, hard-coded, at the top of the rule. Those are only set up to be optional for the XML Template rule in case the user doesn't select anything in the drop-down list; but once you're in JavaScript, the field names are set. Edited March 26, 2013 by Dan Korn Change inter-address delimiter to comma Quote Link to comment Share on other sites More sharing options...
rpaterick Posted March 26, 2013 Author Share Posted March 26, 2013 sure, although (1) you don't specify what the field delimiter should be, and (2) your syntax isn't quite right. You need to add some literal delimiter characters in there, using the + (string concatenation) operator. Assuming that the fields within the address should be delimited with commas, as is the convention for mecard, this will probably work: adr: Optionalfieldorrule(addressfieldorrule) + "," + optionalfieldorrule(cityfieldorrule) + "," + optionalfieldorrule(statefieldorrule) + "," + optionalfieldorrule(zipfieldorrule),or, it might be easier to do all that on a different line, and assign the full address to another variable, which will make the code a little cleaner. So near the top of the rule, you can do this: var address = optionalfieldorrule(addressfieldorrule) + "," + optionalfieldorrule(cityfieldorrule) + "," + optionalfieldorrule(statefieldorrule) + "," + optionalfieldorrule(zipfieldorrule);or, even more succinctly: var address = [ optionalfieldorrule(addressfieldorrule), optionalfieldorrule(cityfieldorrule), optionalfieldorrule(statefieldorrule), optionalfieldorrule(zipfieldorrule) ].join();then the line setting the property of the "info" object can be simply: adr: Address,also, you could change all of those calls to optionalfieldorrule to call fieldorrule, or even simply field, instead, since the field names are all specified, hard-coded, at the top of the rule. Those are only set up to be optional for the xml template rule in case the user doesn't select anything in the drop-down list; but once you're in javascript, the field names are set. fantastic!!! 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.