Skip to main content

Notifications

Microsoft Dynamics GP (Archived)

What is the best way to separate RM00101.CUSTNAME into First and Last?

Posted on by Microsoft Employee

I am return RM00101 data from from a stored procedure, and I need to get First and Last name. I could simply split the CUSTNAME by spaces but is that the best way to do it? My concern is with names that may have more than a single space separating three or more words as a full name. Should I be concerned?

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: What is the best way to separate RM00101.CUSTNAME into First and Last?

    In case anyone else is looking for this, here is the code I wrote to get first and last from CUSTNAME.

    string[] nameParts = strCUSTNAME.Split(' ');

    string first=null, last=null;

    if(nameParts.Length > 2)

    last = nameParts[2];

    else if (nameParts.Length > 1)

    last = nameParts[1];

    //first name is always element 0

    if (nameParts.Length > 0)

    first = nameParts[0];

  • Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: What is the best way to separate RM00101.CUSTNAME into First and Last?

    If all you had to deal with was 2 word names, it would be very easy to do this. However, you have other things to consider:

    1. What if a customer name is First Initial Last

    2. First Middle Last

    3. What if a customer name is a company name

    4. First Initial[.] Last

    The permutations of how a name can be written is the troubling part, not the splitting of the name in itself

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans