rpaterick Posted December 5, 2012 Share Posted December 5, 2012 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. Thanks! Quote Link to comment Share on other sites More sharing options...
step Posted December 5, 2012 Share Posted December 5, 2012 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? Quote Link to comment Share on other sites More sharing options...
rpaterick Posted December 5, 2012 Author Share Posted December 5, 2012 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! Quote Link to comment Share on other sites More sharing options...
step Posted December 6, 2012 Share Posted December 6, 2012 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"; Quote Link to comment Share on other sites More sharing options...
rpaterick Posted December 6, 2012 Author Share Posted December 6, 2012 (edited) Thanks Step. From reading the code, you have up to 3 different options going, correct? Thanks Step, this looks great though! Edited December 6, 2012 by rpaterick Figured out the JavaScript Globals Portion. Quote Link to comment Share on other sites More sharing options...
rpaterick Posted December 6, 2012 Author Share Posted December 6, 2012 One last thing Step. How is the MIDDLE initial handled? Does your client want that left in(avoids doubles) or is the middle initial taken out? Thanks! Quote Link to comment Share on other sites More sharing options...
step Posted December 6, 2012 Share Posted December 6, 2012 (edited) 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 December 6, 2012 by step Quote Link to comment Share on other sites More sharing options...
rpaterick Posted December 6, 2012 Author Share Posted December 6, 2012 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! 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.