mclisa81 Posted June 4, 2009 Share Posted June 4, 2009 Hi, I need a rule that will turn off body pages if certain data is not found in the record. I'm familiar with turning body pages on and off, but I'm hung up on the loop thing, as an example.... Loop through all columns in record 1 (NOTE: there will never be more than 1 record, but could be up to 80 columns to check through) if <I7.pdf> is not found turn off body page <fund_1_1> and <fund_1_2>. if <IL.pdf> is not found turn off body page <fund2_1> and <fund_2_2>. etc, etc. If you can just get me in the "loop", I'd really appreciate it. Let me know if you need further explanation of what I'm looking for. Thanks in advance :)Lisa Link to comment Share on other sites More sharing options...
esmith Posted June 4, 2009 Share Posted June 4, 2009 You'll probably want to wait for Dan Korn to tell us what's wrong with my suggestion, but I wanted to take a stab at it. Unfortunately I do not have time to set up a sample job to try this out on so please proceed at your own risk. OnRecordStart rule: // Pages should be named the same as data in fields with '-front' and '-back' added for sides. (Ex. I7-front; I7-back; IL-front; IL-back; etc.) // Pages should be set to unused. // This code assumes a maximum number of fields reserved for versions to print. // Names of fields that reference versions should just be numbers (1 through n). var TotalFields = n; // change n to equal max number of fields that could reference a printing version. // DO NOT EDIT BELOW THIS LINE var PrintVersions = new Array(); // Populate array with all versions printing in current record for (i = 0;i < TotalFields;i++) { if (Field(i+1) != "") { PrintVersions[i] = Field(i+1); } } // Set which pages print for current record for (n = 0;n < PrintVersions.length;n++) { var Front = PrintVersions[n] + "-front"; var Back = PrintVersions[n] + "-back"; FusionPro.Composition.SetBodyPageUsage(Front,true); FusionPro.Composition.SetBodyPageUsage(Back,true); } Link to comment Share on other sites More sharing options...
mclisa81 Posted June 4, 2009 Author Share Posted June 4, 2009 Thanks for the quick reply Eric. I'll try it in the morning. Link to comment Share on other sites More sharing options...
mclisa81 Posted June 5, 2009 Author Share Posted June 5, 2009 Hi Eric, This was going well this morning until..... I found out there are some (9) 4 page forms in the pdf so how I have them named right now is..... 2 pgrs I7-front1 I7-back1 4 pgrs 4W-front1 4W-back1 4W-front2 4W-back2 etc, etc I'm not that familiar with java, I started to tweek your rule, but I'm stuck. I know it needs to be told which are the 4 pgrs so it can turn on the extra 2 pages. Just in case, the 4 page names are 4W, 4E, 4O, BI, CJ, AF, PR, HK, GV // Pages should be named the same as data in fields with '-front' and '-back' added for sides. (Ex. I7-front; I7-back; IL-front; IL-back; etc.) // Pages should be set to unused. // This code assumes a maximum number of fields reserved for versions to print. // Names of fields that reference versions should just be numbers (1 through n). var TotalFields = 71; // change n to equal max number of fields that could reference a printing version. // DO NOT EDIT BELOW THIS LINE var PrintVersions = new Array(); // Populate array with all versions printing in current record for (i = 0;i < TotalFields;i++) { if (Field(i+1) != "") { PrintVersions = Field(i+1); } } // Set which pages print for current record for (n = 0;n < PrintVersions.length;n++) { var Front1 = PrintVersions[n] + "-front1"; var Back1 = PrintVersions[n] + "-back1"; var Front2 = PrintVersions[n] + "-front2"; var Back2 = PrintVersions[n] + "-back2"; FusionPro.Composition.SetBodyPageUsage(Front1,true); FusionPro.Composition.SetBodyPageUsage(Back1,true); FusionPro.Composition.SetBodyPageUsage(Front2,true); FusionPro.Composition.SetBodyPageUsage(Back2,true); } Thansk for your help! Link to comment Share on other sites More sharing options...
esmith Posted June 5, 2009 Share Posted June 5, 2009 I'm not that familiar with java, I started to tweek your rule, but I'm stuck. I know it needs to be told which are the 4 pgrs so it can turn on the extra 2 pages. Just in case, the 4 page names are 4W, 4E, 4O, BI, CJ, AF, PR, HK, GV First, don't let Dan catch you calling it Java which is different from JavaScript. Second, you have the right idea in your modification, except that I think you will get an error whenever the code tries to compose the 3rd and 4th pages for versions that are only two pages long. To remedy this, you need to specify which versions require the extra two pages. Try replacing this portion of code from your edit above: // Set which pages print for current record for (n = 0;n < PrintVersions.length;n++) { var Front1 = PrintVersions[n] + "-front1"; var Back1 = PrintVersions[n] + "-back1"; var Front2 = PrintVersions[n] + "-front2"; var Back2 = PrintVersions[n] + "-back2"; FusionPro.Composition.SetBodyPageUsage(Front1,true); FusionPro.Composition.SetBodyPageUsage(Back1,true); FusionPro.Composition.SetBodyPageUsage(Front2,true); FusionPro.Composition.SetBodyPageUsage(Back2,true); } with this: // Set which pages print for current record for (n = 0;n < PrintVersions.length;n++) { var Front1 = PrintVersions[n] + "-front1"; var Back1 = PrintVersions[n] + "-back1"; var Front2 = PrintVersions[n] + "-front2"; var Back2 = PrintVersions[n] + "-back2"; FusionPro.Composition.SetBodyPageUsage(Front1,true); FusionPro.Composition.SetBodyPageUsage(Back1,true) ; if ((PrintVersions[n] == "4W") || (PrintVersions[n] == "4E") || (PrintVersions[n] == "4O") || (PrintVersions[n] == "BI") || (PrintVersions[n] == "CJ") || (PrintVersions[n] == "AF") || (PrintVersions[n] == "PR") || (PrintVersions[n] == "HK") || (PrintVersions[n] == "GV")) { FusionPro.Composition.SetBodyPageUsage(Front2,true); FusionPro.Composition.SetBodyPageUsage(Back2,true); } } I'm sure there's a more concise way to compare a value against 9 possibilities, but I'm still learning the advanced JavaScript methods. I modified your code to instruct FP to only include Front2 and Back2 if the value is one of the 9 versions with 4 pages. Link to comment Share on other sites More sharing options...
mclisa81 Posted June 5, 2009 Author Share Posted June 5, 2009 WORKED GREAT! THANKS:) My biggest problem is I'm always learning Javascript when I'm building a job to get it on press. I've always tried to make time to go into the Javascript tutorials online, but that always ends abruptly when "real work" needs to be done, darn! Thanks to you guys, helping out with rules is a lifesaver. And I do learn a lot that way because they are specific to the job I'm working on and I can break them down and add to them. Anyway, thanks again for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.