george.goodeluinas Posted February 15, 2010 Share Posted February 15, 2010 sometimes I need to compose simple letters with names, addresses and dates. The problem is that it's never today's date. Or any predictable date. The customer simply tells me the date when they give me the data file. The date is NOT in the data file. Is there a way using OnRecordStart to bring up a dialog box and ask for the date to use? I've tried using window.prompt("Enter Date ","") but have not been getting very far. Thanks George Quote Link to comment Share on other sites More sharing options...
rpaterick Posted February 15, 2010 Share Posted February 15, 2010 I just have this as a regular rule. return FormatDate(Today(), "lm d, yyyy"); Returns: February 15, 2010 Quote Link to comment Share on other sites More sharing options...
george.goodeluinas Posted February 15, 2010 Author Share Posted February 15, 2010 rpaterick, Thanks for the reply, but that simply provides today's date. I never know what date goes on the letters till the customer tells me what date they want on the letters when they send the data file. In a perfect world the program would ask me for the date when it starts to compose. Thanks George Quote Link to comment Share on other sites More sharing options...
rpaterick Posted February 15, 2010 Share Posted February 15, 2010 rpaterick, Thanks for the reply, but that simply provides today's date. I never know what date goes on the letters till the customer tells me what date they want on the letters when they send the data file. In a perfect world the program would ask me for the date when it starts to compose. Thanks George ahh, gotcha. Yeah, I would think that would be stretching it a bit to have FusionPro prompt you to enter in the date prior to composing. It would be nice if the customer just put the date in the data file, back to the "perfect world." Quote Link to comment Share on other sites More sharing options...
Doug Pershing Posted February 16, 2010 Share Posted February 16, 2010 Hi George, Since the date is not "predictable" it is difficult to create some kind of automated function. We had to deal with this same issue and through talking with the customer we were able to determine exactly why the dates were the they they were. In turn we found a way to calculate them. If there is actually no way to calculate them then somebody needs to enter them somewhere. There are a couple of options: 1. Simply open the rule editor and enter the date you want to use like this: At the top of the JavaScript Globals date = "03/15/2010" Since this is plain text you could literally enter the date exactly as you want it to appear. Now in any rule simply add this to your result. return "Static text before the date " + date + " with the rest of the text after the date." 2. Shift the burden to the customer for the date entry by formating a small Excel file containing the date. Name the Excel file DateMatrix. Give the customer the Excel file to edit. When they send you the new file save it as a csv file. For simplicities sake save this small csv file in the root directory with you FP file. StartDate EndDate January 01, 2010 February 01, 2010 Enter this in the JavaScript Globals: //Set the Date Matrix to retrieve the customer values //Since it is in the root directory no path is needed to locate the file. DateMatrix = new ExternalDataFileEx("DateMatrix.csv", ",") Enter this in the OnJobStart callback rule. This will load the value and set the variables once as the job begins. //Set the date variables StartDate = DateMatrix.GetFieldValue(1,"StartDate"); EndDate = DateMatrix.GetFieldValue(1,"EndDate"); Then create a rule called Offer Dates and enter this: //Use the date variables entered in OnJobStart return "Start Date: " + StartDate + " -- End Date: " + EndDate Then place the rule into a text box on your layout. Whatever is entered in the fields in the Date Matrix csv file will be placed in the layout. I have attached a small example file. I hope this helps. DateTest.zip Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 16, 2010 Share Posted February 16, 2010 Remember that FusionPro Desktop is intended primarily as a design tool for building FusionPro jobs (templates), not really as an end publishing tool. While you can certainly compose your job in FP Desktop, the real power of FusionPro is in its batch (automated) composition capabilities. This batch capability is available in FusionPro Server and FusionPro Direct, in our Web-to-Print solution MarcomCentral, and in many other third-party Web-to-Print solutions which integrate FusionPro behind the scenes. In most of these environments, FusionPro Server is running as a batch process, often on a dedicated, remote server machine, with no GUI context for displaying a dialog to an end user at composition time. Also, while FusionPro does leverage the standard JavaScript 1.5 library, which has its roots in the Netscape/Mozilla Firefox browser and was originally designed for client-side web page scripting, only the core language elements are integrated with FusionPro, and web-specific objects and functions such as window and alert which you might see in online examples of web-specific JavaScript code are not relevant to FusionPro rules. Your "input" in a FusionPro rule is (primarily) the data file, not a web form, and your "output" is, well, your output, not a web page. (However, in addition to returning things that go into text and graphic frames in your composed output, you can also use functions such as Print in FusionPro rules to write to your log file.) So, if you want a context for an end user to be able to enter data in a text box of some kind, either in a desktop or a web application, you will need to create the app and integrate FusionPro Server. In FP Desktop, you will have to manually change either a file from which FusionPro is reading data, or something hard-coded in the job (in a rule or text frame) before composing. Doug's solution is a good one. Quote Link to comment Share on other sites More sharing options...
LesSjo Posted February 16, 2010 Share Posted February 16, 2010 I agree with Dan. Doug's solution is a very good one, which I will probably incorporate in some of my work soon. (Thanks Doug!) However, there is something that everyone may be missing that looks to me to be a very simple fix. The customer simply tells me the date when they give me the data file.To me this implies that there will be one date for the entire job, and just hard-coding the date in the text editor would probably be the easiest solution. http://forums.printable.com/images/icons/icon5.gif Just my $0.02. Quote Link to comment Share on other sites More sharing options...
DSweet Posted February 17, 2010 Share Posted February 17, 2010 George, I have a sort-of-work-around that you can try to use. Why not code the date in a text file that can be read in and assign that date at the very beginning of composition? Try this.... 1) Create a text file called "dateFile.txt" and store it in the same location as the template you are running. In this file give it a record header of "projDate" and then on the next line place whatever date your client wishes to have appear on this run of the letter. 2) In the template itself encode these two rules... as an OnJobStart rule... assignDate = new ExternalDataFileEx("dateFile.txt", "\t"); projectDate = assignDate.GetFieldValue(1, "projDate"); then as a regular text rule... return projectDate 3) You can format the date however you wish within step 2 and use it wherever you wish then in the template by referring to the text-rule you assigned in step 2. By doing this you do not need to alter the template in anyway in order to change the value of "projectDate". It will be assigned whatever value that you place in the text file "dateFile.txt" which can be changed over and over again prior to the start of a composition. And it will be read in and assigned anew everytime the project is run. Hopefully this is a bit more than just 2 cents worth. Good Luck. . Quote Link to comment Share on other sites More sharing options...
george.goodeluinas Posted February 22, 2010 Author Share Posted February 22, 2010 So I'm so late responding.... Been out a few days. Thanks to all those who replied. Dan...Your server explanation made perfect sense. Thanks also to those who suggested the external file. I can see where that can be used in a number of places. Thanks again George Quote Link to comment Share on other sites More sharing options...
LesSjo Posted February 23, 2010 Share Posted February 23, 2010 An external file may be a great solution, but if the date doesn't change from record to record, but may be placed in a number of locations, why not just create a rule that returns a specific date and use the rule in the areas where you need the date returned? return "January 17, 2010";I may be missing something here, but why make things difficult on a simple job? Quote Link to comment Share on other sites More sharing options...
DSweet Posted February 25, 2010 Share Posted February 25, 2010 Yes that would work, however I think that George was trying to not have to change the template time and time again for something as small a change as only a new "letter mailing date". It would be simpler to have an external spot to change something as simple as a run-date on a letter. This was you can run the job off of FusionPro Server and never need to change the template - unless the body of the letter actually changed. . Quote Link to comment Share on other sites More sharing options...
george.goodeluinas Posted February 26, 2010 Author Share Posted February 26, 2010 Lester, The date is the same through out the job, but it changes each time I need to run the job. So I would need to change it either in the rule or in the text file before each time I run the job. 6 Of one, half a dozen of the other. Thanks for the input. Geortge Quote Link to comment Share on other sites More sharing options...
ThePorge Posted May 22, 2015 Share Posted May 22, 2015 Hi George, Since the date is not "predictable" it is difficult to create some kind of automated function. We had to deal with this same issue and through talking with the customer we were able to determine exactly why the dates were the they they were. In turn we found a way to calculate them. If there is actually no way to calculate them then somebody needs to enter them somewhere. There are a couple of options: 1. Simply open the rule editor and enter the date you want to use like this: At the top of the JavaScript Globals date = "03/15/2010" Since this is plain text you could literally enter the date exactly as you want it to appear. Now in any rule simply add this to your result. return "Static text before the date " + date + " with the rest of the text after the date." 2. Shift the burden to the customer for the date entry by formating a small Excel file containing the date. Name the Excel file DateMatrix. Give the customer the Excel file to edit. When they send you the new file save it as a csv file. For simplicities sake save this small csv file in the root directory with you FP file. StartDate EndDate January 01, 2010 February 01, 2010 Enter this in the JavaScript Globals: //Set the Date Matrix to retrieve the customer values //Since it is in the root directory no path is needed to locate the file. DateMatrix = new ExternalDataFileEx("DateMatrix.csv", ",") Enter this in the OnJobStart callback rule. This will load the value and set the variables once as the job begins. //Set the date variables StartDate = DateMatrix.GetFieldValue(1,"StartDate"); EndDate = DateMatrix.GetFieldValue(1,"EndDate"); Then create a rule called Offer Dates and enter this: //Use the date variables entered in OnJobStart return "Start Date: " + StartDate + " -- End Date: " + EndDate Then place the rule into a text box on your layout. Whatever is entered in the fields in the Date Matrix csv file will be placed in the layout. I have attached a small example file. I hope this helps. [ATTACH]210[/ATTACH] I pulled your test file and when validating the rule it returns the date correctly...However when you output this after linking to a data file this doesn't work. I discovered this when trying to implement something similar to this and couldn't get it to work. Don't the two variables you created ("StartDate" and "EndDate") need to be Global in scope rather than rule specific...or are variables under a "OnJobStart" rule global? I moved my variable to a Global scope, but even when moving my variables to a Global scope I can't get this to function correctly. My rule will also return the correct result when validating the rule, but fails when composing. I'm not sure why that is....? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted May 22, 2015 Share Posted May 22, 2015 I pulled your test file and when validating the rule it returns the date correctly...However when you output this after linking to a data file this doesn't work. I discovered this when trying to implement something similar to this and couldn't get it to work. Please be more specific about what doesn't work. Don't the two variables you created ("StartDate" and "EndDate") need to be Global in scope rather than rule specific...or are variables under a "OnJobStart" rule global? All variables in JavaScript are global, unless declared with the "var" keyword. (All variables declared in the JavaScript Globals are also global, even if the "var" keyword is used.) Quote Link to comment Share on other sites More sharing options...
ThePorge Posted May 22, 2015 Share Posted May 22, 2015 In the test file that I pulled from this site the pdf file has a rule called "Offer Dates". If you validate this rule it will return the correct values from the csv file "DateMatrix.csv". I took this FusionPro pdf and Imported a data file. Created a text field and assigned some variable values. I left the field alone that was already created in the file and did not move the DateMatrix.csv file that it is calling for the data. Then I output the file. The dates then didn't work and I got "Start Date: -- End Date:" where I should have gotten "Start Date: January 01, 2010 -- End Date: February 15, 2010" in all the records output. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted May 22, 2015 Share Posted May 22, 2015 In the test file that I pulled from this site the pdf file has a rule called "Offer Dates". If you validate this rule it will return the correct values from the csv file "DateMatrix.csv". I took this FusionPro pdf and Imported a data file. Created a text field and assigned some variable values. I left the field alone that was already created in the file and did not move the DateMatrix.csv file that it is calling for the data. Then I output the file. The dates then didn't work and I got "Start Date: -- End Date:" where I should have gotten "Start Date: January 01, 2010 -- End Date: February 15, 2010" in all the records output. What versions of FusionPro, Acrobat, and the operating system? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted May 22, 2015 Share Posted May 22, 2015 I see what the problem is. The call to the ExternalDataFileEx constructor function should be in OnJobStart, not in the JavaScript Globals. The JavaScript Globals area isn't really a rule; it's intended only for declarations of variables and functions, not for "doing" things, because all of the things that are normally present when rules are run are not yet set up, including the search path, which is needed to resolve the relative path "DateMatrix.csv" to a fully-qualified path. (The functions declared in the JavaScript Globals can "do" things, as long as those functions are only called from actual rules.) So just move this line into the OnJobStart rule: DateMatrix = new ExternalDataFileEx("DateMatrix.csv", ","); And everything will work. Quote Link to comment Share on other sites More sharing options...
ThePorge Posted May 22, 2015 Share Posted May 22, 2015 OSX 10.10.3 Acrobat Build: 11.0.11.18 FusionPro 9.3.6 Quote Link to comment Share on other sites More sharing options...
ThePorge Posted May 22, 2015 Share Posted May 22, 2015 Bam!! Tks all, very good info in this thread. 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.