Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. Google has several well-documented API's that you'd probably find useful for this. Specifically: Places and possibly Maps Geocoding. Note that there are usage limitations tied to the latter. In any event, I've done something similar in the past and had the most success with processing an existing data list of addresses and updating it with the results of the API queries prior to going to FusionPro. So essentially, the script loads a data file, walks through each record calling the script below for each address, and tacks on an additional field for "nearby health care providers" that you could then parse and format within your template. While the script that I wrote is in PHP, you could easily modify it for JavaScript if you'd like: <?php function google_API($url, $params){ $api = '##################################'; // Google API KEY $output = "json"; // json or xml $params = array_filter($params); $params['key'] = $api; $params = implode('&', array_map(function ($v, $k) { return $k . '=' . $v; }, $params, array_keys($params))); $jsondata = json_decode(file_get_contents($url . '/' . $output .'?'.$params)); if ($jsondata->status === "OK"){ return $jsondata; } return ''; } function get_long_lat($address) { $url = "https://maps.googleapis.com/maps/api/geocode"; $parameters = array ( "address" => urlencode($address), "region" => "us" ); $coordinates = google_API($url, $parameters); $lat = $coordinates->results[0]->geometry->location->lat; $lng = $coordinates->results[0]->geometry->location->lng; $result = implode(',', array_filter(array ($lat,$lng))); return $result; } function get_nearby($address){ $url = 'https://maps.googleapis.com/maps/api/place/nearbysearch'; $parameters = array ( "location" => get_long_lat($address), "radius" => 500, "types" => "health|hospital" ); $result = google_API($url, $parameters); if (empty($result)) { return ''; } $locations = array(); foreach ($result->results as $i) { $name = $i->name; if (!empty($name)){ array_push($locations, $name); } } $locations = implode('|', $locations); return $locations; } print get_nearby('1600 Pennsylvania Avenue, Washington DC'); ?> The script above returns a list of places of type "health" or "hospital" within a 500 meter radius of the White House which I've delimited with a pipe so the appended field would have a value of: return Field("nearest health care provider"); // "Harris Teeter|Safeway|Safeway Pharmacy (inside Safeway)|Malone Thomas O DDS|Capitol Hill Dental Associates|Shelton R. Penn, DDS, PC|Comprehensive Psychiatric Emergency Program|Malone Bennye L DDS|Bmarchai Studios|Baker Moorean a DDS|Chardonnay Dialysis Inc|2fitt Wellness|Freed Bodyworks Holistic Wellness Center|Harris Teeter Pharmacy|Think Pilates!|Yorke Leigh V|Khojandi Mohammad MD|Erin Lee, PharmD|Dr. Carlos H. Powers Jr, DDS|William Community Residential" And you could make a list of them like this: return Field("nearest health care provider").split('|').join('\n<br>'); /* Harris Teeter Safeway Safeway Pharmacy (inside Safeway) Malone Thomas O DDS Capitol Hill Dental Associates Shelton R. Penn, DDS, PC Comprehensive Psychiatric Emergency Program Malone Bennye L DDS Bmarchai Studios Baker Moorean a DDS Chardonnay Dialysis Inc 2fitt Wellness Freed Bodyworks Holistic Wellness Center Harris Teeter Pharmacy Think Pilates! Yorke Leigh V Khojandi Mohammad MD Erin Lee, PharmD Dr. Carlos H. Powers Jr, DDS William Community Residential */
  2. You just need to make a variable width table using TextMeasure: var str = ToUpper(Field("City")) + ' SECURITY NOTICE'; var space = 900; // .125 inches == 900 function getTextWidth(input){ var tm = new FusionProTextMeasure; tm.font = "Univers 65 Bold"; tm.pointSize = "14pt"; tm.CalculateTextExtent(input); var result = tm.textWidth; return (result*1.1) + space*2; } var table = new FPTable(); table.AddColumn(getTextWidth(str)) var row = table.AddRow(); var cell = row.Cells[0] cell.SetBorders('Thin','Black','Top','Bottom','Right','Left'); cell.VAlign = "Middle"; cell.Margins = {'Left':space, 'Right': space, 'Top': space/10, 'Bottom': space/10}; row.SetContents(str); return table.MakeTags().replace(/^\<table/, "<table alignment=center"); Here's a similar thread.
  3. You're referring to the "Properties palette" and you probably just closed it by accident.You can bring it back by going to: FusionPro > Palettes > Properties. If it's indicating that it should already be visible, click "Reset All."
  4. By the way, just as a little explanation about the 'rows' variable since I know it looks kind of weird: --pg subtracts 1 from the page number. !--pg Converts the number to a boolean (true/false). In this case we're testing that the page number minus one is zero; if it is, the boolean returns true and if it's greater than 0 it returns false. !--pg+2 The binary value of the boolean (1: true, 0: false) is converted to an integer by performing arithmetic on it. In this case we're adding 2 so that the number of rows will be 2 when the page is greater than one (0 + 2 = 2) and 3 when then page number is 1 (1 + 2 = 3). It by no means has to be written that way. I was just saving a few keystrokes but it could certainly be written in a more easy-to-read format: var rows = pg==1 ? 3 : 2;
  5. Sure, you could determine the number of marks (rows) to add based on what page the record is on: var pg = FusionPro.Composition.currentPageNumber; var rows = !--pg+2; var OMR = new FPTable(); OMR.AddColumns(7200); for (var i=0; i<rows; i++) { var row = OMR.AddRow(); row.minHeight = 1800; //specified in hundredths of a point row.Cells[0].SetBorders('Medium', 'Black', 'Top'); } return pg%2 ? OMR.MakeTags() : '';
  6. Okay, it sounds like you're going to want to make a text rule to return those values and then apply it to the frames in which you'd like for the barcode to display. Is that right? So the "total pages" are the "total pages of a particular record," is the "current page" the "current page of a particular record" or the "current page of the output file?" There are methods to handle both but for the sake of example, I'm going to assume you're just talking about the current page in the record. I don't understand what you mean by that. Can you elaborate on what you mean by "calling page numbers in the empty rules?" Are you referring to rules that return a null value or empty string? If so, why are you worried about calling the page number? Easy enough. You can just return an empty string in your text rule when the current page mod 2 is 0. Or just don't put a text frame with that rule in it on even pages. Page 1 has a special check digit that signifies the start of a document like... a 1? I'm not sure what your intent with this "check digit" is. It seems like that information is already included in the barcode but I'll just assume that you want the last two digits to be "01" if it's the first page in the document and "00" if it's any other page in the document. I also just assumed you wanted to make a 3 of 9 barcode but you should be able to easily swap that out with whatever format you prefer: var id = 'CN61341'; // Your Client ID field would go here var pg = FusionPro.Composition.currentPageNumber; var pgs = FusionPro.Composition.totalPages; var check = pg == 1 ? 1 : 0; // Format pg, pgs, & check to 2 digits and join the string. var digits = [pg,pgs,check].map(function(s){ return Str(FormatNumber('00',s));}).join(''); // If the current page is odd, return the barcode return pg%2 ? Make39Barcode(id + digits) : ''; That would go in a text rule that is set to "re-evaluate for every text flow" and "treat strings at tagged text" and then you just insert it into your text frames.
  7. How does a "single page PDF" file have 112 pages? Are you saying that you have a 112 page PDF file that you want FP to impose as if each page were a record? You can do that – you just have to make FP think that each page is a different record. If you're wanting to turn the 112 page PDF into the template, you'll need an OnRecordStart rule that looks like this: FusionPro.Composition.repeatRecordCount = 112; var i = FusionPro.Composition.repeatRecordCount + 1; while (--i) FusionPro.Composition.SetBodyPageUsage(i, i == FusionPro.Composition.repeatRecordNumber) That is: Setting the "record" to repeat 112 times (once per page in the template) and for each repeat, it turns off every page with the exception of the current repeat number. So, for the first repeat it turns off pages 2–112, for the second repeat it turns off page 1 and pages 3–112, until it gets to page 112.
  8. If the "Name" field is empty, you want to return some left-justified text and the "Name" field? That seems odd. Either way, the tag you're looking for is the paragraph tag (page 42 of the TagsRefGuide.pdf documentation). The "quad" attribute will allow you to adjust the alignment with values of "L," "R,", "C," and "J" (left, right, centered, and justified respectively). Keep in mind that a paragraph tag by default starts a new paragraph (adding a line break) so if you want to avoid a line break, use the 'br' attribute and set it to false. So in your situation, you just want to determine if the alignment should be a "C" or an "L" based on the value of the "Name" field: var align = Field("Name") ? 'C' : 'L'; var str = Field("Name") ? 'Centered Text' + Field("Name") : 'Left Justified Text'; return '<p br=false quad=' + align + '>' + str;
  9. No, they don't need to be kept if you're composing jobs locally. If you're composing a job on the server, you'd have to specify a '.dif' file and a '.cfg' file to use on the command line. Otherwise, I believe FusionPro just regenerates those files every time you compose the job based on the most recent composition settings.
  10. What version of FusionPro are you using locally and on the server? Did you set the leading in the "paragraph" window of the text editor or did you tag it in a rule? What are your legacy line leading settings? Without knowing more information it's really hard to say what's going on.
  11. I don't think there's much about JavaScript in the manuals because that's already pretty well-documented across the internet. If you're new to JavaScript, checkout JavaScript.com or CodeAcademy. Those are two free resources that will (at the very least) get you familiar with the syntax. Aside from that, my other suggestion would be to just participate on this forum. If there's something specific to a template you're working on that you can't figure out, search the forum – it is extremely possible that it's been asked before and if not, feel free to post it because I'm sure someone else will also want to know.
  12. If you have a rule that's returning a field's value, you can do something like this: var number = Field("Your Field") || 0; return number; The first line says: "Set the value of 'number' equal to the value of the field 'Your Field' or if a value does not exist for 'Your Field,' set 'number' equal to zero." If you aren't using rules to return your fields and you're simply inserting a field into the text editor you can make an OnRecordStart callback rule that replaces the value of any empty field with 0: for (var i in FusionPro.Fields) if (!Field(i)) FusionPro.Composition.AddVariable(i, 0); The above code walks through every field in your data file at the beginning of each record and checks to see if it is empty. If the field is empty, it's value is set to zero.
  13. No. What makes you think that? Notice that there's no "Field" function wrapping it. Here's what's happening: You have an array that contains the values of fields P1-P17, the value of the protocol field, and a static 'ps' string. Then that array is filtered and the empty positions are removed. So for example: var arr = ['val1','','val3',''].filter(String); // arr[1] & arr[3] are removed // now arr == ['val1', 'val3'] var [a,b,c,d] = arr; // this assigns variables a,b,c,d to each position in the 'arr' array return b; // returns 'val3' Once the array is filtered and the remaining positions are assigned to their respective variables, the values are checked against the 'pdfMap' object to determine which graphic to return. So: pdfMap = { 'val1' : 'PdfforValue1.pdf', 'val2' : 'PdfforValue2.pdf', 'val3' : 'PdfforValue3.pdf', 'val4' : 'PdfforValue4.pdf', }; var graphic = pdfMap[b]; // PdfforValue3.pdf In your specific case, with the addition of the static 'ps' string means that it will never be filtered out because it is not empty. The value "ps" is simply used to map which PDF to pull in for that value.
  14. Cool, then the code I wrote earlier will work: var frameName = FusionPro.Composition.CurrentFlow.name; var [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18] = [Field("P1"),Field("P2"),Field("P3"),Field("P4"),Field("P5"),Field("P6"),Field("P7"),Field("P8"), Field("P9"),Field("P10"),Field("P11"),Field("P12"),Field("P13"),Field("P14"),Field("P15"),Field("P16"),Field("P17"),Field("PROTOCOL"),'ps'].filter(String); var pdfMap = { "1": "1_cardiacas.pdf", "2": "2_Insuficiencia.pdf", "3": "3_Problemas respiratorios.pdf", "4": "4_Dialisis renal.pdf", "5": "5_Diabetes.pdf", "6": "6_Depresion.pdf", "7": "7_Otras condiciones.pdf", "8": "8_No hay condiciones.pdf", "9": "9_Medicamentos.pdf", "10": "10_Varios medicamentos.pdf", "11": "11_Caidas.pdf", "12": "12_Baston.pdf", "13": "13_Necesidad.pdf", "14": "14_Llamar.pdf", "15": "15_Hospitalizacion.pdf", "16": "16_Perdida.pdf", "17": "17_Confianza.pdf", "201": "18_Closing Letter.pdf", "701": "18_Closing Letter.pdf", "702": "18_Closing Letter.pdf", "703": "18_Closing Letter.pdf", "704": "18_Closing Letter.pdf", "705": "18_Closing Letter.pdf", "706": "18_Closing Letter.pdf", "707": "18_Closing Letter.pdf", "708": "18_Closing Letter.pdf", "710": "18_Closing Letter.pdf", "711": "18_Closing Letter.pdf", "712": "18_Closing Letter.pdf", "713": "18_Closing Letter.pdf", "714": "18_Closing Letter.pdf", "715": "18_Closing Letter.pdf", "716": "18_Closing Letter.pdf", "717": "18_Closing Letter.pdf", "718": "18_Closing Letter.pdf", "719": "18_Closing Letter.pdf", "720": "18_Closing Letter.pdf", "721": "18_Closing Letter.pdf", "722": "18_Closing Letter.pdf", "723": "18_Closing Letter.pdf", "801": "18_Closing Letter.pdf", "901": "18_Closing Letter.pdf", "902": "18_Closing Letter.pdf", "904": "18_Closing Letter.pdf", "502": "19_Closing LetterCIP.pdf", "ps": "Closing Letter_PS" } var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : NullResource();
  15. Can you be a little more descriptive about what you're trying to do? While I appreciate you attaching your template, you didn't supply any of the graphic elements so it's kind of hard to get a grasp of what you're trying accomplish. Are you wanting to add a specific PDF before every blank that may be needed (PDF, blank, PDF, blank, etc) or are you trying to add a specific PDF before the blanks start (PDF, blank, blank, blank, etc). Sample output would be very helpful. If it's the latter, you could probably do this: var frameName = FusionPro.Composition.CurrentFlow.name; var [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18] = [Field("P1"),Field("P2"),Field("P3"),Field("P4"),Field("P5"),Field("P6"),Field("P7"),Field("P8"), Field("P9"),Field("P10"),Field("P11"),Field("P12"),Field("P13"),Field("P14"),Field("P15"),Field("P16"),Field("P17"),Field("PROTOCOL")[color="red"], 'BeforeBlanks'[/color]].filter(String); var pdfMap = { "1": "Heart disease1.pdf", "2": "Heart failure2.pdf", "3": "Breathing3.pdf", "4": "Kidney4.pdf", "5": "Diabetes5.pdf", "6": "Depression6.pdf", "7": "7_Other Health Conditions.pdf", "8": "8_No Health Conditions Listed.pdf", "9": "************9.pdf", "10": "Multiple medications10.pdf", "11": "Falls11.pdf", "12": "Cane12.pdf", "13": "Caregiver13.pdf", "14": "Calling14.pdf", "15": "Overnight15.pdf", "16": "Memory loss16.pdf", "17": "17_Confidence in Filling Out Med Forms.pdf", "201": "Closing letter18.pdf", "701": "Closing letter18.pdf", "702": "Closing letter18.pdf", "703": "Closing letter18.pdf", [color="Red"]"BeforeBlanks": 'SpecificPDF.pdf', [/color] } var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : NullResource();
  16. That hasn't happened to me with FusionPro but it has happened to me with other plug-ins for Acrobat (I'm looking at your Pitstop). It's definitely annoying but I think the fault lies with Acrobat rather than FP. While I know this isn't a fix, the way I got around it was moving the tools to the "Quick Tools" bar. "Quick Tools" show up in the bar running along the top of your Acrobat window along with the "Create," "Open," "Save," etc. buttons. This seemed more inline with the way I was used to interacting with Acrobat 9 and helped me avoid those collapsable panels all together. View > Show/Hide > Toolbar Items > Quick Tools Then you can add the FP shortcuts from Third Party > FusionPro to the "Quick Tools to Show" section and arrange them to fit your preference. And on the off chance that you're an Alfred Powerpack user, I've created a simple Alfred Workflow that you can grab from my github page lets you change your data file, load fonts, compose, re-compose, and collect your job using keyboard shortcuts.
  17. Is this for a MarcomCentral store front? If so, I think you can use the "IsPreview()" function to trigger whether the image is returned or not: return IsPreview() ? CreateResource('YourGraphic.pdf','graphic') : NullResource();
  18. var n=0; for (var i in FusionPro.Fields) if (Field(i)) n++; return n;
  19. Generally speaking: the more information the better. And while I'll continue to claim that any code that I post on this forum is "just an example to demonstrate my approach," if I'm provided field names, I'll usually try to tailor the solution as closely as I can. Well, yeah exactly. Hopefully you got rid of the 'for' loop as well since it was going from 1-8 pushing fields "Headline1" - "Headline8" (and the corresponding body field) into the 'r' array. You'll have to post the actual code that you're using instead of telling me what you took out/added because if I add the fields to the array as I mentioned (note that it's a 2D array – an array within an array), I don't get an error. So, r[0] should return [Field('0EmailHeading'), Field('0EmailBody')] and r[0].join('<br>') should return Field('0EmailHeading') <br> Field('0EmailBody'). Okay, 'r' is the array of your paragraphs (headline and body respectively). Putting 'r' inside of brackets like that just puts the entire array into a new array. And since the array only has one position, it won't be joined by a break tag because there's no other position to join it with. The fact that nothing is returned makes me think you've declared the 'r' array incorrectly but without seeing your code I wouldn't know that. No the headlines fields and body fields should be added in a 2D array for my code to work. For a next step, I would recommend reading up on arrays and the 2D array link I mentioned earlier. I think that playing around with some arrays will help you figure out what's missing in your code because it sounds like you're pretty close to getting this working the way you want.
  20. I suppose I'm just hesitant to alter those templates too much. (Though you could argue that simply adding a space to the replacement strings would have kept the code closer to the original than the changes that I made do.) But your comment reminded me of this gif.
  21. I figured that was probably the case but you didn't offer up any of that information in your original email so i took a guess. Just put them into the array: var r = [ [Field('0EmailHeading'), Field('0EmailBody')], [Field('0WebHeading'), Field('0WebBody')], [Field('0POSHeading'), Field('0POSBody')] ];
  22. You shouldn't have to convert the entire rule and edit the original JavaScript code to add a space. You could simply create a "wrapper" rule to return the modified string: return Rule("Change phone format Rule").replace(')', ') '); I guess if you really wanted to, you could update the XML that creates that rule (though I would recommend creating a new file instead). In addition to making it a new "rule" I would also strongly recommend adding a checkbox to the rule to toggle the space rather than add the space to the source and end up in the same predicament when you decide a space isn't needed. The resulting file would be placed in "/Library/Application Support/PTI/FusionPro/Plug-ins/TemplateXML" on each of the machines you want to add the new rule to. <?xml version="1.0" encoding="ISO-8859-1" ?> <template_rule name="*MODIFIED* Change phone rule" version="1.0" type="text" taggedtext="false"> <rulename language="en-US">[MODIFIED] Change phone format Rule</rulename> <rulename language="de">Regel zum Ändern des Telefonformats</rulename> <rulename language="fr">Règle Changer le format téléphonique</rulename> <rulename language="es">Regla Cambiar formato de teléfono</rulename> <rulename language="it">Regola modifica formato numero di telefono</rulename> <Comment language="en-US">This rule has been MODIFIED to change the value of a phone number field to a particular format of your choice.</Comment> <Comment language="de">Mit dieser Regel wird der Wert eines Telefonnummernfeldes in ein Format Ihrer Wahl geändert.</Comment> <Comment language="fr">Cette règle va changer la valeur d’un champ de numéro de téléphone en un format particulier de votre choix.</Comment> <Comment language="es">Esta regla cambiará el valor del campo de un número de teléfono a un formato que usted elija.</Comment> <Comment language="it">La regola consente di cambiare il valore di un campo numero di telefono in un campo con qualsiasi formato.</Comment> <Description language="en-US">Please specify the appropriate values.</Description> <Description language="de">Geben Sie die entsprechenden Werte an.</Description> <Description language="fr">Veuillez spécifier les valeurs appropriées.</Description> <Description language="es">Especifique los valores que correspondan.</Description> <Description language="it">Specificare i valori appropriati.</Description> <fieldlist> <field type="FIELDLIST" required="true"> <fieldname>Var1</fieldname> <prompt language="en-US">Choose the phone field:</prompt> <prompt language="de">Feld "Telefon" wählen:</prompt> <prompt language="fr">Choisissez le champ de téléphone :</prompt> <prompt language="es">Elija el campo de teléfono:</prompt> <prompt language="it">Scegliere il campo telefono:</prompt> <value></value> </field> <field type="PICKLIST" subtype="ListBox" required="true"> <fieldname>CaseSelection</fieldname> <prompt language="en-US">Choose the format:</prompt> <prompt language="de">Wählen Sie das Format:</prompt> <prompt language="fr">Choisissez le format :</prompt> <prompt language="es">Elija el formato:</prompt> <prompt language="it">Scegliere il formato:</prompt> <value></value> <picklist> <item><prompt>123.456.7890</prompt><value>Format 1</value></item> <item><prompt>123-456-7890</prompt><value>Format 2</value></item> <item><prompt>(123)456-7890</prompt><value>Format 3</value></item> <item><prompt>(123)456.7890</prompt><value>Format 4</value></item> </picklist> </field> <field type="CHECKBOX"> <fieldname>includeSpace</fieldname> <prompt language="en-US">Space after area code when using parentheses?</prompt> <prompt language="de">De ruimte na het netnummer bij het gebruik van haakjes?</prompt> <prompt language="fr">Espace après le code de la zone lors de l'utilisation parenthèses?</prompt> <prompt language="es">¿Espacio después de código de área al utilizar paréntesis?</prompt> <prompt language="it">Spazio dopo prefisso quando si utilizza parentesi?</prompt> <value>0</value> </field> </fieldlist> <code> if(CaseSelection == "Format 1") { var formatStyle01 = "$1.$2"; //simple 7 digit phone var formatStyle02 = "$1.$2.$3"; //simple 10 digit phone var formatStyle03 = "+$1 $2.$3.$4"; //10 digit phone starts with 1 var formatStyle04 = "$1.$2.$3 ext.$4"; //10 digit phone with extension var formatStyle05 = "+$1 $2.$3.$4 ext.$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1.$2 ext.$3"; //7 digit phone with extension var thisNumber = Field(Var1); return formatNumber(Trim(thisNumber)); } if(CaseSelection == "Format 2") { var formatStyle01 = "$1-$2"; //simple 7 digit phone var formatStyle02 = "$1-$2-$3"; //simple 10 digit phone var formatStyle03 = "+$1 $2-$3-$4"; //10 digit phone starts with 1 var formatStyle04 = "$1-$2-$3 ext.$4"; //10 digit phone with extension var formatStyle05 = "+$1 $2-$3-$4 ext.$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1-$2 ext.$3"; //7 digit phone with extension var thisNumber = Field(Var1); return formatNumber(Trim(thisNumber)); } if(CaseSelection == "Format 3") { var formatStyle01 = "$1-$2"; //simple 7 digit phone var formatStyle02 = "($1)$2-$3"; //simple 10 digit phone var formatStyle03 = "+$1 ($2)$3-$4"; //10 digit phone starts with 1 var formatStyle04 = "($1)$2-$3 ext.$4"; //10 digit phone with extension var formatStyle05 = "+$1 ($2)$3-$4 ext.$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1-$2 ext.$3"; //7 digit phone with extension var thisNumber = Field(Var1); return formatNumber(Trim(thisNumber)); } if(CaseSelection == "Format 4") { var formatStyle01 = "$1.$2"; //simple 7 digit phone var formatStyle02 = "($1)$2.$3"; //simple 10 digit phone var formatStyle03 = "+$1 ($2)$3.$4"; //10 digit phone starts with 1 var formatStyle04 = "($1)$2.$3 ext.$4"; //10 digit phone with extension var formatStyle05 = "+$1 ($2)$3.$4 ext.$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1.$2 ext.$3"; //7 digit phone with extension var thisNumber = Field(Var1); return formatNumber(Trim(thisNumber)); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // DO NOT EDIT BELOW THIS LINE /////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// return formatNumber(Trim(thisNumber)); function formatNumber(number01){ var format = [formatStyle01,formatStyle02,formatStyle03,formatStyle04,formatStyle05,formatStyle06].map(function(s){ return includeSpace ? s.replace(')', ') ') : s; }); var pattern01 = /^(\d{3})[^\d]*(\d{4})$/; // //2201727 or 220-1727 or 220- 1727 var pattern02 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; // 8002201727 or 800-220-1727 or (800)220-1727 or (800) 220-1727 var pattern03 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; // 18002201727 or 1-800-220-1727 or +1 (800) 220-1727 var pattern04 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 800-220-1727 ext 12345 or (800) 220-1727 ext 12345 var pattern05 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 1-800-220-1727 ext 12345 or +1 (800) 220-1727 ext 12345 var pattern06 = /^(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 2201727 ext 1234 or 220-1727 ext 1234 or 220- 1727 ext 1234 var patternEndExt = /(.)[x#n](.)/; var patternStart1 = /^[\D]*[1]/; if(number01.match(pattern01)){ number01 = number01.replace(pattern01, format[0]); return number01; } else if(number01.match(pattern02)){ number01 = number01.replace(pattern02, format[1]); return number01; } else if(number01.match(pattern03)){ if (number01.match(patternStart1)){ number01 = number01.replace(pattern03, format[2]); return number01; } else { return number01; } } else if(number01.match(pattern04)){ number01 = number01.replace(pattern04, format[3]); return number01; } else if(number01.match(pattern05)){ number01 = number01.replace(pattern05, format[4]); return number01; } else if(number01.match(pattern06)){ number01 = number01.replace(pattern06, format[5]); return number01; } else { //return "no match any pattern"; return number01; } } </code> </template_rule>
  23. I believe that "FieldChanged" takes the name of a field (in your case "Site") as its parameter rather than the actual value of the field. Try this: if (FieldChanged("Site")) FusionPro.Composition.OpenNewOutputFile(Field("Site") + "." + FusionPro.Composition.outputFormatExtension);
  24. You just need to put your tags in quotes: if (Field("Header One")== "" && Field("Paragraph One") == "") return "" else return [color="Red"]'[/color]<color name="Light Blue"><f name="HelveticaNeueLT Std Med">[color="Red"]' + [/color]Field("Header One")[color="Red"] + '[/color]</f></color><br><color name="Black"><f name="HelveticaNeueLT Std Lt">[color="Red"]' + [/color]Field("Paragraph One")[color="Red"]+ '[/color]</f></color><br>[color="Red"]'[/color];
×
×
  • Create New...