Jump to content

Pull graphic based on data file name


Recommended Posts

Is there any way to set up a graphic switch rule based on the data file name that is being used?

 

For example, if I have two separate mailing lists that need to remain separate... one list has a file name of "WPC_JUNE_1ST.csv" and a second list with a file name of "WPC_JUNE_3RD.csv"...

 

Is there a javascript rule that would look at the actual name of the data that was being linked at the time to the FusionPro document, and pull an appropriate postal indicia graphic resource based on the "1ST" or the "3RD" part of the data file name?

 

I realize, a basic switch rule would work also, if I added a column of data calling out the mail class, into the lists themselves, but I'd rather not do that in this case if I can avoid it.

 

Any help would be most appreciated.

Link to comment
Share on other sites

Dan,

 

Thank you very much. This is going to work just great!

 

Could you explain what/how the (/.*_(.*)\.[^.]+$/, "$1") part is filtering? Sometimes my data file names aren't as clean as the ones I gave in my example (WPC_JUNE_3RD.csv), and I'd like to be able to use this with data file names that are a little more complex, but that I'd just add a "..._1ST" or "..._3RD" at the end of the file name.

Link to comment
Share on other sites

Dan,

 

Thank you very much. This is going to work just great!

 

Could you explain what/how the (/.*_(.*)\.[^.]+$/, "$1") part is filtering? Sometimes my data file names aren't as clean as the ones I gave in my example (WPC_JUNE_3RD.csv), and I'd like to be able to use this with data file names that are a little more complex, but that I'd just add a "..._1ST" or "..._3RD" at the end of the file name.

That's a JavaScript Regular Expression being used in a String.replace call. It's kind of a shorthand notation for a "search and replace" operation on a string.

 

Basically, it means this: "In the string, after zero or more characters of anything, followed by an underscore, and then anything else (remembering what that "anything else" was), followed by a period (the beginning of the file extension), followed by something that's not a period, at the end of the string, return the part we remembered." In other words, return anything before an underscore and the last period (dot).

 

So, as long as the file name has an underscore before the part you want to capture, and the file extension after it, this logic should work.

Link to comment
Share on other sites

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...