web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

  • MG-16101311-0 Profile Picture
    26,225 on at

    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

  • Verified answer
    Community Member Profile Picture
    on at

    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];

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans