Jump to content

Anyone deal with PURLS & Same Names


rpaterick

Recommended Posts

For a campaign of 20,000 records, we have 293 sets/groups of names that have the same name.

 

Customer would like the following formatting(up to 3 names the same):

Name 1: JohnSmith@.edu

Name 2: John.Smith@.edu

Name 3: John Smith@.edu

 

Any idea how to handle this with automation? I really do not want to go through all 293 groups and manipulate.:o

 

Thanks!

Link to comment
Share on other sites

Are you saying that out of 20,000 records, 293 records have the same name in fields Name1, Name2, and Name3? And you want them formatted differently?

 

Can you post an example? Or better describe what you're asking?

 

Out of the 20,000 records, there are 293 groups or 586 duplicate names.

 

ex: Aaron Smith

 

I have to have one Aaron Smith like this:

AaronSmith@.edu

 

The next Aaron Smith to come along needs to be like this:

Aaron.Smith@.edu

 

Both Aaron Smith's live at different addresses but would need their own "unique" purl ID when they log onto the website that is their own.

 

Thanks!

Link to comment
Share on other sites

This is probably not the best way to do this. I feel like this is probably something that should be handled at the data level. That being said, this works for me but it just doesn't preview correctly. Hopefully it can get you headed in the right direction though:

 

JavaScript Globals:

var names = [];

 

OnRecordStart:

Array.prototype.contains = function (element) {
 for (var i = 0; i < this.length; i++) {
   if (this[i] == element) {
     return true;
   }
 }
 return false;
}

var fullName = Field("FullName");
var sep = ["",".","_"];
var n = 0;

for (var i=0; i<3; i++) {
   if (names.contains(fullName.replace(/\s/g,sep[n]))){
       n++;
       }
   else {
       names.push(fullName.replace(/\s/g,sep[n]));
       i=3;
       }
}

 

Create a text rule that returns the PURL:

return names[CurrentRecordNumber()-1] + "@.edu";

Link to comment
Share on other sites

Basically the code initiates an array of names in the JavaScript Globals.

 

At the start of each record, it checks to see if a name formatted without a space is in the array (meaning it's been used already). If it isn't, it pushes the name into that array. If it is, it formats it with a different option from the "sep" array.

 

Then the PURL rule calls the formatted name from the names array.

 

In regards to the middle initial, the code replaces spaces with a separator from the "sep" array. If the name is passed to the code in this format: "John W Smith", the code will return "JohnWSmith" or "John.W.Smith", etc.

Edited by step
Link to comment
Share on other sites

In regards to the middle initial, the code replaces spaces with a separator from the "sep" array. If the name is passed to the code in this format: "John W Smith", the code will return "JohnWSmith" or "John.W.Smith", etc.

 

 

Thanks, this is very helpful!

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