Jump to content

step

Registered Users - Approved
  • Posts

    962
  • Joined

Everything posted by step

  1. You just need to change it to "ByRow" instead of "ByRows".
  2. I don't think you can do it from the text editor but you can create a rule to return your paragraph: var yourParagraph = 'Flexitarian freegan polaroid paleo kickstarter blue bottle. Pop-up echo park thundercats dreamcatcher, small batch sriracha migas green juice. Crucifix gentrify live-edge, wolf thundercats schlitz before they sold out slow-carb distillery cliche coloring book squid lomo gluten-free kinfolk. Fixie gastropub tilde blue bottle green juice, tattooed pop-up gluten-free kombucha poke pok pok iceland kickstarter. Godard lyft venmo, cliche iPhone twee intelligentsia bushwick sartorial swag selfies 3 wolf moon. Slow-carb farm-to-table tousled cornhole, aesthetic small batch ramps williamsburg. Man braid af marfa, pork belly direct trade before they sold out enamel pin asymmetrical bushwick squid.'; return '<p br=false quad="JC">' + yourParagraph; Or if you want to typeset your paragraphs in the text editor, you can name your that text frame (ex: "ParagraphFrame") and set the alignment in your OnRecordStart callback: FindTextFrame('ParagraphFrame').content = FindTextFrame('ParagraphFrame').content.replace(/quad="\w+"/g, 'quad="JC"');
  3. The reason I used "apply" was to be able to use the same array of field names for both the "SortBy" and the "FindRecords" functions. It seemed more manageable when altering which field names by which you'd want to search as opposed to remembering to change the code in both places. Now admittedly, it seems a tad "overkill" for only two values (even more-so now that Troy says he's only keying off of one field value) but to me it seems a little less repetitive to only have to enter the field names once. The reason that the function no longer works for Troy is because he renamed the "fields" array to "field" – which is the name of the argument being passed to the function. He left the reference to "fields" when defining the "rec" variable but it's no longer defined: function ExField([color="Red"]field[/color]) { var ex = new ExternalDataFileEx('/path/to/secondaryData.csv', ','); var [color="red"]field[/color] = ['GL Name']; var cursor = ex.SortBy.apply(ex, field); var rec = cursor.FindRecords.apply(cursor, [color="red"]fields[/color].map(Field)).shift() || -1; return ex.GetFieldValue(rec, field); }
  4. What version of FusionPro are you using? In FP9, you can filter an external data file by sorting on field names and finding records with specified values for the sorted field names: var ex = new ExternalDataFileEx('/path/to/secondaryData.csv', ','); var cursor = ex.SortBy('Affiliation', 'Department'); var rec = cursor.FindRecords('***', 'YYY'); return ex.GetFieldValue(rec, 'Address'); The above code returns the value of the "Address" field for the record in "secondaryData.csv" with a value of "***" in the "Affiliation" field and a value of "YYY" in the "Department" field. Assuming that you'll want the values of "Affiliation" and "Department" in the external data file to correspond to the values of identically named fields in your primary data file, you could do this: var ex = new ExternalDataFileEx('/path/to/secondaryData.csv', ','); var cursor = ex.SortBy('Affiliation', 'Department'); var rec = cursor.FindRecords(Field("Affiliation"), Field("Department")); return ex.GetFieldValue(rec, 'Address') + '<br>' + ex.GetFieldValue(rec, 'City') + ', ' + ex.GetFieldValue(rec, 'St') + ' ' + ex.GetFieldValue(rec, 'Zip'); Or make a global function to clean it up a little: function ExField(field) { var ex = new ExternalDataFileEx('/path/to/secondaryData.csv', ','); var fields = ['Affiliation', 'Department']; var cursor = ex.SortBy.apply(ex, fields); var rec = cursor.FindRecords.apply(cursor, fields.map(Field)).shift() || -1; return ex.GetFieldValue(rec, field); } Then your rule could just be: return ExField('Address') + '<br>' + ExField('City') + ', ' + ExField('St') + ' ' + ExField('Zip');
  5. I can't speak to how MarcomCentral works but my assumption would be that MarcomCentral would create an accurate preview.
  6. If you have FusionPro Server, you can manipulate the width, height, x, and y coordinates of frames from the OnRecordStart callback: var frame1 = FindGraphicFrame("First Graphic Frame"); var frame2 = FindGraphicFrame("Second Graphic Frame"); // 5x7 frame frame1.x = 0.5 * 7200; // in hundreths of a point frame1.y = 0.5 * 7200; // in hundreths of a point frame1.width = 5 * 7200; // in hundreths of a point frame1.height = 7 * 7200; // in hundreths of a point // 8x10 frame frame2.x = 6 * 7200; // in hundreths of a point frame2.y = 0.5 * 7200; // in hundreths of a point frame2.width = 8 * 7200; // in hundreths of a point frame2.height = 10 * 7200;// in hundreths of a point
  7. If you're composing the job with an imposition applied, the cfg file will contain: UseImpositionDefFile=Yes You can access the values in the cfg file through the JobOptions property at composition time: if (FusionPro.Composition.JobOptions["UseImpositionDefFile"] == 'Yes') { // code to execute when imposing }
  8. Here's a little one-liner that does the same thing from the replace function. It also truncates the cents when dealing with an even dollar amount. return Field("LASTGIFT").replace(/\$((??!\.00).)*).*/, function(s, p){ return +p < 25 ? '$25' : '$' + p; });
  9. The way the code I wrote works is this: It creates an array of phone numbers which will be in this format: "f. ###.###.###" The filter method is applied to the array of numbers to remove the empty ones (more on this below). The remaining elements of the array are joined by a bullet. The filter method is the part that I think is causing some confusion. If you take a look at its definition I've linked, you'll read that the filter method tests each element of the array against a function that will either return true or false. If the result is true, the element is kept. If it is false, it is removed from the array. So, for the sake of this example, let's assume some values for your fields: Rule("tagPhone1") = "d. " Rule("Change phone format Rule") = "555.555.5555" Rule("tagPhone2") = "f. " Rule("Change phone format Rule") = "" /* var office = "d. " + "555.555.5555"; var fax = "f. " + ""; */ var office = Rule("tagPhone1") + Rule("Change phone format Rule"); var fax = Rule("tagPhone2") + Rule("Change fax phone format Rule"); /* var numbers = ["d. 555.555.5555", "f. "] */ var numbers = [office, fax]; The comments in the code above show what happens to the code when a number ("Change fax phone format Rule" in this example) is empty. We know that we want to get rid of the "f. " element since it doesn't have a corresponding number associated with it so we have to write a function for the filter array that will return false when an element doesn't fit the format of: "letter, period, space, phone number". That can be done a number of ways but the way I chose was to remove elements that contained a space but did not have a character following the space. I'll name the function "HasCharacterAfterSpace" and re-write the code like this to better illustrate: /* function HasCharacterAfterSpace(element) { return element.match(/.*\s(?=.)/); } // The below calls: HasCharacterAfterSpace("d. 555.555.5555"); <-- true // then calls : HasCharacterAfterSpace("f. "); <-- false numbers = ["d. 555.555.5555", "f. "].filter(HasCharacterAfterSpace); // Values that returned false are removed from the array: numbers = ["d. 555.555.5555"]; */ numbers = numbers.filter(function(m){return m.match(/.*\s(?=.)/);}); The next part is just joining the remaining elements in the array with something. In your case, you're joining them with a bullet wrapped in color tags but it could be anything you like. And as is the case in this example, arrays containing only one element won't be "joined" but will still be converted to a string. It's also worth noting that arrays can contain more than two elements. So you could have all of your phone numbers in one array like this: var numbers [ "d. 555.555.5555", "f. ", "c. 444.444.4444" ]; // returns 'd. 555.555.5555 <color name="PANTONE 801"> • </color>c. 444.444.4444'; return numbers.filter( function(element){ return element.match(/.*\s(?=.)/); }).join('<color name="PANTONE 801"> • </color>'); Hopefully that gives you a better understanding of what the code is doing and how to make the filtering work for an array of elements that likely don't contain any spaces (websites and email address).
  10. Similar to the "color" tag, there is also a "font" tag. You can find an example of how it works and a better explanation than I could give you on page 47 of the TagsRefGuide PDF that comes with FusionPro. FusionPro > Documentation > Tags Reference return Field("Phone") ? '<f name="Different Font">t.</f> ' : '';
  11. Since you're adding color tags to the bullet, you need to check the box beside "Treat returned strings as tagged text" at the top of your rule.
  12. Replace the bullet in the join method with the tag I posted in my first reply: var office = (Rule("tagPhone1")) + (Rule("Change phone format Rule")) var fax = (Rule("tagPhone2")) + (Rule("Change fax phone format Rule")) var numbers = [office,fax]; return numbers.filter(function(m){return m.match(/.*\s(?=.)/);})[color="Red"].join('<color name="PANTONE 801"> • </color>')[/color]; Also, there's nothing wrong with putting parentheses around your "Rule" functions, but you don't need them. So, you could save yourself a few keystrokes and define your variables as: var office = Rule("tagPhone1") + Rule("Change phone format Rule"); var fax = Rule("tagPhone2") + Rule("Change fax phone format Rule");
  13. Take a look at this thread: http://forums.pti.com/showthread.php?t=3554 It discusses your scenario almost exactly. The only difference would be the color bullet points. Assuming you've defined "PANTONE 801" in your FP template, you can apply color to a bullet like this: return '<color name="PANTONE 801"> • </color>';
  14. You could use a function like this one: function formatBraille(number) { // Remove any characters that aren't a-j // and consider the number a match if it has 7 or 10 letters in it number = number.replace(/[^a-j]/gi, '').match(/^(.{3})?(.{3})(.{4})$/); // If no match is found, return an empty string if (!number) return ''; // Remove the original string, leaving only the // captured groups in the 'matched' array number.shift(); // Remove any values that are 'undefined' and join with a hyphen return '#' + number.filter(Boolean).join('-'); } You can put that in your JavaScript Globals so that you can call it from any rule, or you can just put it in the same rule and call it like this: return formatBraille('fageeeabcd'); // #fag-eee-abcd If you wanted to take it a step further, you could have the function convert regular phone numbers into the braille format: function formatBraille(number) { number = number [color="Red"].split('') .map(function(s) { return /\d/.test(s) ? Chr(96 + Int(s)) : s; }) .join('')[/color] .replace(/[^a-j]/gi, '') .match(/^(.{3})?(.{3})(.{4})$/); if (!number) return ''; number.shift(); return '#' + number.filter(Boolean).join('-'); } Then you could pass either format and get the braille format back: return formatBraille('(617) 555-1234'); // #fag-eee-abcd
  15. Are you using multiple paragraphs? You can try this: var color = Field("Color"); return FusionPro.Colors[ToLower(color)] ? '<span color="' + color + '">' : '';
  16. You just need a rule that returns the color tag at the beginning of your text box. The following rule will return the color tag if the color in the "Color" field is a defined FusionPro color: var color = Field("Color"); return FusionPro.Colors[ToLower(color)] ? '<color name="' + color + '">' : '';
  17. I don't know why the data would preview a certain way and compose another. It sounds like the data string is being converted to a number. Are you using a rule to return it? If so, what is the rule? You could explicitly specify that the result should be a string: return Str(Field("RateX")); Or you could use the FormatNumber function: return FormatNumber('0.00', Field("RateX"));
  18. Oh okay, you can still do that: return Field("Email").replace(/@.*/, '') + '@domain.com'; Or if you want to do it all from within the replace method: return Field("Email").replace(/(.)(@.*)?$/, '$1@domain.com');
  19. Not sure I follow. If they don't supply the '@domain.com', it doesn't need to be removed. return 'jdoe'.replace(/@.*/, ''); // returns jdoe return 'jdoe@gmail.com'.replace(/@.*/, ''); // returns jdoe
  20. return Field("Email").replace(/@.*/, '');
  21. var fields = [Field("1"), Field("2"), Field("3"), Field("4"), Field("5")].filter(String); return fields.length > 1 ? 'results' : 'result';
  22. Is there a reason you're using a table for that layout? It seems to me you could simplify things by just doing this: return externalDF.FindRecords('Fund', Field("Fund")) .map(function(s){ var quote = TaggedTextFromRaw(externalDF.GetFieldValue(s, 'Quote')); var name = TaggedTextFromRaw(externalDF.GetFieldValue(s, 'Recipient Name_cal')); return quote ? [quote, '<f name=Gotham-Medium>' + name].filter(function(p) { return RawTextFromTagged(p); }).join(' - ') : ''; }).filter(String).join('<br>'); But if you want to use a table for some reason, this change should give you the results you want: if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true) { Rule("OnJobStart"); } //Get a count of the total number of records in the external data file numRecsExtDF = externalDF.recordCount; /*============================================================================= || Create arrays to hold values that match the CID of the client's record ||=============================================================================*/ var QuoteMatch = []; var RecipientMatch = []; // Step through the external data file and push matches into their respective variables if there is a match for (var i=1; i <= numRecsExtDF; i++) { if (externalDF.GetFieldValue(i, 'Fund') == Field("Fund")) { [color="Red"]if (quote = TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Quote'))) QuoteMatch.push(quote); RecipientMatch.push(TaggedTextFromRaw(externalDF.GetFieldValue(i, 'Recipient Name_cal'))); }[/color] } } /*============================================================================= || Create the table ||=============================================================================*/ new FPTable; var myTable = new FPTable; myTable.AddColumns(47000); // interate through the length of the arrays (data matches from external data file) and create rows for (var i = 0; i < QuoteMatch.length; i++) { // TABLE CONTENT FORMATTING var row = myTable.AddRow(); for (var c = 0; c < myTable.Columns.length; c++) { var cell = row.Cells[c]; cell.Font = "Gotham-Book"; cell.PointSize = "10"; cell.TextColor = "Black"; cell.ShadeColor = "Black"; cell.Margins = { Top:20, Bottom:100, Right:20, Left:20}; cell.VAlign = "Left"; cell.HAlign = "Left"; // CREATE CONTENT FOR EXTERNAL DATA FILE RECORDS row.SetContents(QuoteMatch[i] + " –"+'<f name=Gotham-Medium>'+ RecipientMatch[i]); } } return myTable.MakeTags();
  23. You can repeat a record like this: FusionPro.Composition.repeatRecordCount = 3; // repeats a record 3 times If you want to change which page is enabled based on the number of times a record has been repeated, you can do that like this: // Prints page 1 the first time the record is repeated and page 2 the 2nd and 3rd time the record is repeated FusionPro.Composition.SetBodyPageUsage(1, FusionPro.Composition.repeatRecordNumber == 1); FusionPro.Composition.SetBodyPageUsage(2, FusionPro.Composition.repeatRecordNumber > 1); Both of those rules would go in OnRecordStart
  24. // Name C M Y K new FusionProColor('New Color', 100, 0, 0, 0); return '<color name="New Color">Text String></color>';
  25. You can determine the length of a string by accessing the '.length' property. Keep in mind, though, that spaces are included in that value: return 'A String'.length; // returns 8 Splitting a string creates an array of strings which are accessible by calling their position in the array. So that works fine when there are 6 words but asking for the 6th word (CustTypeSplit[5]) in a two-word array will return an error because that position doesn't exist: return ["One","Two"][5]; // undefined You can account for that by writing it like this: CustTypeSplit = Field("NAME1").split(" "); first = CustTypeSplit[0] || ""; middle = CustTypeSplit[1] || ""; last = CustTypeSplit[2] || ""; last2 = CustTypeSplit[3] || ""; last3 = CustTypeSplit[4] || ""; last4 = CustTypeSplit[5] || ""; Yeah, there is. You can do it like this: var field = Field("NAME1"); if (field.length > 31) { field = field.split(' ').map(function(s) { return Left(s,1); }).join(' '); } return field; Or: return (f = Field("NAME1")).length > 31 ? f.split(' ').map(function(s) { return Left(s, 1); }).join(' ') : f;
×
×
  • Create New...