Jump to content

Recommended Posts

Posted

k... here goes....

 

Using 9.1 Windows

 

We have a project that need to output multiple files based on a specific data field. I have accomplished that with PTI's help. What I am wondering is this.

 

I have a data file with 760 names, addresses and other misc data. There is a field named "Plan" which changes from person to person. There are 100 different data strings that can possibly be assigned to each person's "plan". I have sorted the data so it is in order of the "plan" field (so the first 51 have the same plan , the next 32 have the same plan, etc.)

 

On output is it possible to tell FP to create a folder named whatever is in the "plan" field and create multiple pdfs within that folder? When it finishes that bunch of 51, create a new folder named the next "plan" and output it's files.

 

Sorry so long and winded, but any help would be appreciated

 

Thanks

Mike

Posted
On output is it possible to tell FP to create a folder named whatever is in the "plan" field and create multiple pdfs within that folder? When it finishes that bunch of 51, create a new folder named the next "plan" and output it's files.

Not with FusionPro 9.1, no. However, we are adding this functionality to FusionPro 9.2.

Posted

Mike

I have a job I do every 4 months or so and it's kind of like this. I have changed some of the code to make it more like your example.

My output folders are always the same names so I made a folder on my desktop called AllPlans and then made sub folders called Plan1, Plan2, Plan3, etc

You could then search your Plan field for the correct file location and then name the output file with the plan and name.

 

var str = ToLower(Field("Plan"));

 

if (str.search("plan1") != -1)

outpath = "/Users/MacPro/Desktop/AllPlans/Plan1/";

 

else if (str.search("plan2") != -1)

outpath = "/Users/MacPro/Desktop/AllPlans/Plan2/";

 

else if (str.search("plan3") != -1)

outpath = "/Users/MacPro/Desktop/AllPlans/Plan3/";

 

else if (str.search("plan4") != -1)

outpath = "/Users/MacPro/Desktop/AllPlans/Plan4/";

 

 

filename = Str(Field("Plan") + "-" + Field("Name"));

outfile = outpath + filename;

 

if (FieldChanged("Plan"))

 

FusionPro.Composition.OpenNewOutputFile(outfile + "." + FusionPro.Composition.outputFormatExtension);

Posted (edited)

This is what i got... I am getting errors

I think it has to do with my path

 

var str = ToLower(Field("WelcomePackageCode"));

 

if (str.search("74289NY0010001-01ONEC") != -1)

outpath = "c:/Files/7-7 to Print/74289NY0010001-01ONEC/";

 

else if (str.search("74289NY0010001-01ONEE") != -1)

outpath = "c:/Files/7-7 to Print/74289NY0010001-01ONEE/";

 

else if (str.search("74289NY0010001-01ONES") != -1)

outpath = "c:/Files/7-7 to Print/74289NY0010001-01ONES/";

 

else if (str.search("74289NY0010001-01ONFM") != -1)

outpath = "c:/Files/7-7 to Print/74289NY0010001-01ONFM/";

 

else if (str.search(74289NY0020001-01ONEC") != -1)

outpath = "c:/Files/7-7 to Print/74289NY0020001-01ONEC/";

 

else if (str.search("74289NY0020001-01ONEE") != -1)

outpath = "c:/Files/7-7 to Print/74289NY0020001-01ONEE/";

 

else if (str.search("74289NY0020001-01ONES") != -1)

outpath = "c:/Files/7-7 to Print/74289NY0020001-01ONES/";

 

else if (str.search("74289NY0020001-01ONFM") != -1)

outpath = "c:/Files/7-7 to Print/74289NY0020001-01ONFM/";

 

 

filename = Str(Field("WelcomePackageCode") + " " + Field("LastnameRP") + "_" +

Field("firstnameRP") + " " + Field("SubscriberID"));

outfile = outpath + filename;

 

if (FieldChanged("WelcomePackageCode"))

 

FusionPro.Composition.OpenNewOutputFile(outfile + "." + FusionPro.Composition.outputFormatExtension);

Edited by DCS
Posted

What are the error messages?

I work on a mac and it's a little different than a pc. I know I had a problem with the number of chars in the length of the path. I also didn't use any special chars. One thing is that when I assign the data to the str variable I made it to lower case and you are search for uppercase. Another thing Dan Corn said somewhere is to put in \\ instead of single \ in the path but he also said you could put forward slashes to / instead. Just giving you some options to try.

 

outpath = "c:\\Files\\7-7 to Print\\74289NY0010001-01ONES\\";

Posted

Couple of issues I see here. First, you are setting the value of the "WelcomePackageCode" to all lowercase and then searching it for uppercase letters. Secondly, I think you also need to escape spaces in your path. I think you could simplify your code to look like this:

 

outpath = "c:\\Files\\7-7\ to\ Print\\" + Field("WelcomePackageCode") + "\\";
filename = Field("WelcomePackageCode") + " " + Field("LastnameRP") + "_" + Field("firstnameRP") + " " + Field("SubscriberID");
outfile = outpath + filename;

if (FieldChanged("WelcomePackageCode"))
   FusionPro.Composition.OpenNewOutputFile(outfile + "." + FusionPro.Composition.outputFormatExtension);

Posted

Thanks Guys for all the help...

was playing around late into the night...

(obviously I am a complete noob to this)

 

couple of issues....

 

1. I get it to make a file named properly but only the first one of the "plan"

the rest just get named 1.pdf, 2.pdf , etc.

 

2. I can't seem to get the composed files into their proper folders. They are being made in my directory that the original PDF is in, even after I code the "//"

 

Thanks Again

Mike

Posted

Mike

Just checking that you already made the folders in the path you are using. They have to be created by you because PTI can't make them yet.

I just noticed that I have a field that is unique to all records that is in the if (FieldChanged("Dealer Code")).

Do you have a field that is unique maybe the name field you can put in the

if (FieldChanged("Name")) instead of if (FieldChanged("WelcomePackageCode"))

Also you are using the \\ not // right?

Posted

thanks for the help once again....

 

This is what I have and I am getting this error:

OnNewOutpuFile, Line 19: Syntax Error: missing ) after argument list

 

here is the code:

 

var str = ToLower(Field("WelcomePackageCode"));

 

if (str.search("74289NY0010001-01ONEC") != -1)

//outpath = "c:\Files\7-7 to Print\74289NY0010001-01ONEC\";

outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

 

else if (str.search("74289NY0010001-01ONEE") != -1)

//outpath = "c:\Files\7-7 to Print\74289NY0010001-01ONEE\";

outpath = "c:\\ Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

 

else if (str.search("74289NY0010001-01ONES") != -1)

//outpath = "c:/Files/7-7 to Print/74289NY0010001-01ONES/";

outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

 

else if (str.search("74289NY0010001-01ONFM") != -1)

//outpath = "c:/Files/7-7 to Print/74289NY0010001-01ONFM/";

outpath = "c:\\ Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

 

else if (str.search(74289NY0020001-01ONEC") != -1)

//outpath = "c:/Files/7-7 to Print/74289NY0020001-01ONEC/";

outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

 

else if (str.search("74289NY0020001-01ONEE") != -1)

//outpath = "c:/Files/7-7 to Print/74289NY0020001-01ONEE/";

outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

 

else if (str.search("74289NY0020001-01ONES") != -1)

//outpath = "c:/Files/7-7 to Print/74289NY0020001-01ONES/";

outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

 

else if (str.search("74289NY0020001-01ONFM") != -1)

//outpath = "c:/Files/7-7 to Print/74289NY0020001-01ONFM/";

outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

 

 

filename = Field("WelcomePackageCode") + " " + Field("LastNameRP") + "_" + Field("FirstNameRP") + " " + Field("SubscriberID");

outfile = outpath + filename;

 

if (FieldChanged("SNSTrackingID"))

 

FusionPro.Composition.OpenNewOutputFile(outfile + "." + FusionPro.Composition.outputFormatExtension);

 

 

Thanks

Mike

Posted

Well, the error message is telling you that the error is on line 19. You're missing a double quote. This line:

else if (str.search(74289NY0020001-01ONEC") != -1)

Should be this:

else if (str.search([color=SeaGreen]"[/color]74289NY0020001-01ONEC") != -1)

But I don't really understand why you have all those chained "if...else if" statements which all do exactly the same thing. Do you always want to do this?

outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";

If so, then just do that, unconditionally, without all the "if" statements. You can just get rid of lines 1 through 32, which reduces the entire rule to this:

outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";
filename = Field("WelcomePackageCode") + " " + Field("LastNameRP") + "_" + Field("FirstNameRP") + " " + Field("SubscriberID");
outfile = outpath + filename;

if (FieldChanged("SNSTrackingID"))
 FusionPro.Composition.OpenNewOutputFile(outfile + "." + FusionPro.Composition.outputFormatExtension);

Of course, the only condition you really care about here is "if (FieldChanged("SNSTrackingID"))", so I would just put everything in a block based on that condition, like so:

if (FieldChanged("SNSTrackingID"))
{
 outpath = "c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\";
 filename = Field("WelcomePackageCode") + " " + Field("LastNameRP") + "_" + Field("FirstNameRP") + " " + Field("SubscriberID");
 outfile = outpath + filename;
 FusionPro.Composition.OpenNewOutputFile(outfile + "." + FusionPro.Composition.outputFormatExtension);
}

Which of course can be reduced even further, to this:

if (FieldChanged("SNSTrackingID"))
   FusionPro.Composition.OpenNewOutputFile("c:\\Files\\7-7ToPrint\\" + Field("WelcomePackageCode") + "\\" +
       Field("WelcomePackageCode") + " " + Field("LastNameRP") + "_" + Field("FirstNameRP") + " " + Field("SubscriberID") +
       "." + FusionPro.Composition.outputFormatExtension);

  • 2 weeks later...
Posted

Thanks for everyone's help on this....

 

One more question - Is there any way to tell FP to only use certain pages from the PDF. eg. pages 2-12

 

Thanks

Mike

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...