PermaLinkBigBill's Big 7, number 309:34:32 AM
Written By : Scott Good

Parsing out names, once and for all

You know the problem: You've got a list of names you want to sort alphabetically by last name but the first and last names aren't in separate fields, it's all just one big string. No big deal, right? You just look for the space:

LastName := @Right(ContactName; " ");

Piece of cake. Oh, wait. What about double last names? You know, like St. John or Van Dyke? Just taking things right of the space isn't going to cut it there. You might take everything right of the first space, but what if there's a middle name?

Or, triple last names? Like, van der Wald. It just keeps getting worse.

While your head is spinning about that, consider that some of these people have titles they like to see in their names as suffixes. Or, prefixes, even. Some have more than one. So, you've got this name you want to arrange in a last-name-first format:

Dr. Horace Allen van der Wald, Esq., MD, PhD

Something like that.

And, just to make it interesting, let's say that intermixed in your list of contact names are Contact documents you used for related but different purposes, like keeping track of numbers for the Help Desk or Technical Support or the Marketing Department. Those names, of course you wouldn't want rearranged. You don't want it to say "Desk, Help" you want it to still say "Help Desk." Right next to "van der Wald, Dr. Horace Allen, Esq., MD, PhD."

That's what you want. So, the question is, how on earth can you possibly write a view column formula to do it?

You know how on the old show they used to say, "This is a job for Superman!"? Around here the sentence was, "This is a job for BigBill!" We had a need to do exactly what I've described above, for our own client contact database.

This was definitely a job for Bill. This was the kind of thing that made the rest of us grin with pleasure at the thought of not having to figure out and made him grin with pleasure at the challenge.

It sounds impossible to do. Hell, it is impossible to do by mere mortals like you and me. But, he worked it out. You can get your own copy of the code here. Feel free to use it as you see fit, but please leave the copyright statement in place.

At the top, just under the copyright is a place where it says YourFieldNameHere. Replace that with...you guessed it...the name of the field on your form which contains the name. If you actually have a field called Name, you'll need to do some find-and-replacing.

Further down the page, in all caps, are the words it's looking for in terms of multiple last names, prefixes and suffixes, along with words that let it know this is not a name but, rather, something like "Help Desk." If you think of one we've missed, add it to whichever list it fits into (in all caps).

Pretty simple really (once Bill finished all the code and handed it over).

All I can think when I use this is, "Damn. I wish I'd given him something hard to do."

Comments :v

1. Barb10/17/2006 10:22:20 AM


I have a field on a form that pulls the username from the address book. When I apply this formula to another field on the form, it doesn't pull the last name properly for a person whose firstname is Maria and last name is Armstong Murphy. The formula results in Murphy, Maria Armstrong when it should be Armstong Murphy, Maria. Can you help?




2. Scott Good10/17/2006 03:20:37 PM
Homepage: http://www.scottgood.com


Hi Barb,

Ugh. You could just hypenate her name

Seriously, though, the code has reserved words (like "van") that it recognizes as patterns that might be part of a multiple-word last name.

The problem, of course is "Armstrong" is a pretty common last name in and of itself but adding "ARMSTRONG" to the list of "DblLastNames" variables (put it all in caps) will probably take care of the problem...as long as you don't have anybody with that as a middle name.

If that doesn't work you could hack it with something built around Maria's specific name (hey, I SAID it was a hack).

Or, hyphenate...




3. John Dillon06/27/2007 12:58:17 PM
Homepage: http://www.perforce.com/wrt


I've got a "Person Lookup Class" script library to handle this problem once and for all. Look for it in an upcoming edition of Lotus Advisor magazine. It's a new and improved version of the one I presented at the Advisor Summit last August in Phoenix. If you can't wait, check the Advisor site for ways to download the article and old code.

Basic approach is to look up the name in the NAB, then grab the values out of the last name and first name fields and build a new "Last, First" value.

I do it in LotusScript, but you could undoubtably create JavaScript and Formula variations.

Rally on!

John




4. Scott Good06/27/2007 03:37:52 PM
Homepage: http://www.scottgood.com


Hi John,

I'm looking forward to that article. The first one in your series on writing classes in LotusScript was great. Having said that, what you're talking about, while it would be terrific to have, is a bit different from what we were doing here.

In ours, we were trying to solve the problem of correct last-name-first sorting (1) in a view and (2) from a single field containing the entire name including prefixes and suffixes. Because of the view, we were stuck with @Formulas (and built it long before you could do looping).

Looking forward to your next installment...

Scott




5. jazzy07/07/2008 01:06:58 AM


I have some big problem till yesterday it was okay but today i opened my domino 6.5 server loged in as administrator when i click people on the left pane of console the list of people apearing wrongly first name is not appearing first and the last name is appearing first which is not desired one for my company coz when user open the address book they see last name first and they are killing my brain out please help me out init




Enter Comments^


Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-) :cry: :-\ :huh: ;-) :cool: :grin: :emb: :laugh: :-p :lips: :-( :rolleyes: :-o :-D :angry: :-x
bold italic underline Strikethrough





Remember me    

Disclaimer & Copyright
Monthly Archive
Contact me...
Racing sponsors and such...

Thank you sponsors!

GABlogLogo.jpg

GOODAero

GOODAero specializes in building aerodynamic products for racing cars. Our first product, the GOODAero Raptor wing is available at a surprisingly reasonable price (under a grand) for a full carbon, full-sized, racing wing. Check it out.


Infinite Fiberworks Co, a great source for high-quality Porsche fiberglass parts

Infinite Fiberworks Co.

If you are looking for fiberglass for Porsches, IFC is the place to go. I have used parts from most of the major suppliers and IFC's are easily the highest quality and the most reasonably-priced. Contact Mike at Infinite Fiberworks for more information.

Located in Racine, OH (so far Southeast they're almost in West Virginia), IFC's goal is to be The Best. Give 'em a try.


Bent or ugly wheels? Call Wheel Medic!

Wheel Medic & The Round House

Whether you need to repair, repaint, refinish or just replace your wheels, the guys at Wheel Medic/Round House can get you back on the road in no time!

Wheel Medic, Inc is a family-owned company which specializes in the repair and restoration of aluminum wheels.

The Round House was founded to service Wheel Medic's clients looking for more than just repair work...from custom wheel colors to high-end wheel applications and body kits, the Round House is there to serve the discriminating automotive enthusiast.


Used Porsche parts, great prices!

A Part Above

Looking for used parts for 944s, 924s, 968s or other late-model water-cooled Porsches? Contact John at A Part Above.

Located in Strongsville, OH (20 miles south of Cleveland) their goal is to provide top quality parts and services. I can tell you, John is great to work with and the prices? Very hard to beat.


SMRT Motorsports wants you!

SMRT (that's short for Skid Mark Racing Team), a very-

loosely organized band of fun-loving friends who enjoy auto racing (heck, cars in general), and the occasional adult beverage, wants you to be a part of our team.

Go here to find cool T-shirts, sweatshirts, caps and mugs with the SMRT team logo.

The BlogRoll
Lotus Domino ND6 RSS News Feed RSS Comments Feed Geo URL RSS Validator Blog Admin Lotus Geek Open Notes Picture Database OpenNTF BlogSphere
Calendar
February 2012
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
By Category
What I do for a living


I am the President of Teamwork Solutions a long-time Lotus, now IBM, Premier Partner.

With offices in Columbus and Cincinnati, Ohio, we specialize in custom application development for IBM Lotus Notes, Domino, and related technologies. Our software product, ProcessIt! (see below), is quite possibly the world's best, most powerful and easiest-to-use workflow tool for Notes and the web.

Our clients are some of the world's largest corporations along with others that aren't so big.

We do excellent work, quickly, and often on a fixed-fee basis. We'd love to talk to you about your next project.




I am a Contributing Author to Lotus Advisor Magazine, with more than 40 articles under my belt.

I've written how-to series (serieses?) on LotusScript, JavaScript, Cascading Style Sheets (CSS), and now, AJAX (Asynchronous JavaScript and XML), as well as a bit on miscellaneous web development topics.


TheView.jpg

I also write for The View as of the July/August issue where I showed how to take an ugly Notes applications and make it beautiful with just a few minutes' (careful) work.



I am the chief architect and one of two primary developers for what many consider the best all-around workflow tool for Notes/Domino, anywhere, regardless of price.

It's called ProcessIt!, and you can read all about it at www.notesworkflow.com but the bottom line is this: ProcessIt! is fast and easy to learn, extremely powerful, and can be used by mortals. Even--dare I say it?--common users.

You can spend a lot more on a workflow tool but you won't be able to do a lot more for all the extra money.

Don't believe me? Download and try it for free for 60 days.



GTSLogoSm.gif
Copyright Porsche and NASA...not me!

I race a Porsche 944 S2 in National Auto Sport Assocation events and am the 2008 National Champion in NASA's GTS2 class.

Blame this event, a few years ago, for starting that particular money drain all over again.

In support of my habit, I am the NASA Great Lakes Region's GTS (German Touring Series) Director.

I'm also a Nationally-Certified Instructor for the Porsche Club of America and am in charge of classroom sessions for the Mid-Ohio region when we are doing high performance driving events.

In a prior racing life, I was the Midwestern Regional Formula Atlantic Champion and, in 1991, the Ohio Vally Region of SCCA's Regional Driver of the Year (but that, alas, went away when my credit cards let go of the rope!).




I'm writing a book...or at least trying to.

It's murder mystery in which, not too surprisingly, the main character runs a small software company and races cars for fun. Oh yeah, and lives near where I do.

Just where do they come up with these crazy ideas?

Facebook