#1
|
|||
|
|||
![]()
I am setting up a business card for a digital storefront using FusionPro. The customer has certain optional certifications that could appear after their name.
The customer wants the DSF user to be able to select from a list of certifications rather than enter the certifications manually, so I have set up a pick list as a multi-select box in my FusionPro HTML Form. I have entered all of the possible certifications (AAMS®, CFP®, CFA, etc.) in the pick list as well as a “none” choice in case they don’t have any certifications. The FusionPro fields are as follows: <Fullname><Certifications>Q1: Does anyone know how the data is output from the storefront if multiple entries are selected from a multi-select box? Is it an array? Q2: Assuming the data is an array, can anyone suggest a javascript that will extract each entry from the array, then format the certifications so they have a comma and space after each one. * Keep in mind the options are none, one selection, or multiple selections. The first line of the business cards should look like: Joe Smith, AAMS®, CFAI am envisioning a script that basically says, If the field Certifications = “none” then return “”, else return the field Certifications, but with formatting “entry1, entry2, entry3, etc.” I can create basic javascripts using the FusionPro building blocks, but this may be out of my league. I don’t know how to handle the formatting part. Can someone help me with this please? |
#2
|
||||
|
||||
![]() Quote:
At any rate, the DSF application can't really provide anything other than an input data file to FusionPro, with data fields and values in per-record key-value pairs. I don't see how it could possibly inject a JavaScript array into a rule. So if DSF did have a multi-select list, it would probably put the selections in the data in one of two ways: It either (A) creates a list of fields with indices, something like "Certification1", "Certification2", etc., or (B) it sets the value of the Certifications field to some kind of delimited list, with the values separated by some delimiter other than the main data file delimiter. (So if the data file is, say, tab-delimited, it might put semicolon-delimited values in the data for the pick list.) I suspect that you'll have to just set up multiple fields yourself, such as "Certification1", "Certification2", etc., and make them all pick lists, so that the end user can select multiples. But you don't have to guess what the data field values coming out of DSF are. You have full access to all of the data in the FusionPro template. So you can write a rule like so: Code:
var result = []; for (var f in FusionPro.Fields) result.push(f + ": " + Field(f)); return result.join("\n"); Or you can see the field values in the composition log (.msg) file by changing the last line to this: Code:
Print(result.join("\n")); Quote:
Code:
var result = []; // iterate Certification*** fields var numCertificationFields = 10; // set this to however many you defined for (var i = 1; i < numCertificationFields ; i++) result.push(Field("Certification" + i)); Code:
var result = []; // iterate Certification*** fields for (var i = 1; i < 10 ; i++) { try { result.push(Field("Certification" + i)); } catch (e) { // no more Certification*** fields break; } } Code:
result = result.filter(String); // remove empty values Quote:
Code:
if (!result) return ""; // no certifications //else return ", " + result.join(", "); Code:
var result = []; // iterate Certification*** fields var numCertificationFields = 10; // set this to however many you defined for (var i = 1; i < numCertificationFields ; i++) result.push(Field("Certification" + i)) result = result.filter(String); // remove empty values if (!result) return ""; // no certifications //else return ", " + result.join(", ");
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral 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)}); ![]() |
#3
|
|||
|
|||
![]()
Dan,
Thanks for your response. In FusionPro I have set my certifications field up as a "pick list" when defining my HTML form, then as "check box list" in DSF so that the user is able to make multiple selections. The data that gets returned is then a list of the selected items separated by commas but no spaces (AAMS,CAP,CFA). That's good, but now I need to add spaces between them and some of the entries need register R marks. I have included the ® marks in the value of my pick list in the FusionPro HTML form, but I am not getting that mark in the returned data from DSF. Again, a DSF issue, not a FusionPro issue. I have learned from the customer that there will be a maximum of three certifications for each business card so I think I will try a different tactic on this and go with multiple fields as you suggested; Certification1, Certification2, etc. and make each one a dropdown list. I think I can make this work on my own that way, but now I don't know how to handle the register R marks. I will try create a rule with tagged text for the register mark and make it superscript. Hopefully I can get something to work. I'm still learning and experimenting. |
#4
|
||||
|
||||
![]() Quote:
But yes, this is good! Since we know it's a comma-delimited list, we can just call String.split on it to get our array, and use the Array.join to put them back into a string delimited by commas and spaces. The rule now becomes much simpler: Code:
var result = Field("Certification").split(',').filter(String); // remove empty values if (!result) return ""; // no certifications //else return ", " + result.join(", "); Quote:
Code:
var result = Field("Certification").split(',').filter(String).map(function(s){return s.replace("(R)","®");}); if (!result) return ""; // no certifications //else return ", " + result.join(", "); Quote:
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral 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)}); ![]() |
#5
|
|||
|
|||
![]()
Great script Dan.
It almost works perfectly. The problem I am having now is that even when the DSF user doesn't select any of the certifications, there is still a comma after the name: Fname Lname, I tried to resolve that by adding a "none" choice and editing the script code you provided: Code:
if (Field("Certifications")!="none") { var result = Field("Certifications").split(',').filter(String).map(function(s){return s.replace("(R)","®");}); if (!result) return ""; // no certifications //else return ", " + result.join(", "); } else return “”; How do I edit your original code to eliminate the comma after the name when the user makes NO selection at all? Your help is greatly appreciated! Happy Holidays. |
#6
|
|||
|
|||
![]()
Hi Dan.
I finally got my rule to work. I ended up combining my "Name" field and my "Certifications" field into one FusionPro Rule. With this rule, the user can: (1) make no selections at all for the Certifications; the rule returns "" (2) they can choose "none" and any number of other selections for the Certifications; the rule returns "" since the first string in the array will be "none" (3) they can make multiple selections for the Certifications that do NOT include "none"; the rule returns the certifications they selected Here's the final code I ended up with: Code:
var result = Field("Certifications").split(',').filter(String).map(function(s){return s.replace("(R)","®");}); var firstChoice = Field("Certifications").split(',').shift() if (firstChoice=="none"||result=="") return Field("Name"); else return Field("Name")+", " + result.join(", "); Dan, thanks for your help. I couldn't have done it without you. |
#7
|
||||
|
||||
![]() Quote:
Code:
var result = Field("Certification").split(',').filter(String).map(function(s){return s.replace("(R)","®");}); if (!result.length) return ""; // no certifications //else return ", " + result.join(", "); Code:
var result = Field("Certification").split(',').filter(String).map(function(s){return s.replace("(R)","®");}); return result.length ? ", " + result.join(", ") : ""; Code:
var result = Field("Certification").split(',').filter(String).map(function(s){return s.replace("(R)","®");}); result.unshift(Field("Name")); return result.join(", "); Code:
var s = Field("Name") + "," + Field("Certification"); return s.split(',').filter(String).map(function(s){return s.replace("(R)","®");}).join(", ");
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral 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)}); ![]() |
![]() |
Tags |
array, fusionpro, javascript, mulit-select box |
Thread Tools | Search this Thread |
Display Modes | |
|
|