Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Want to first and last string in ax 2012

Posted on by 145

Hello Everyone,

Kindly help me I want below result in name field , How would I get.

I want first and last string compulsary and then first letter from second string, Some Example I have given as show below.

Name in the system

Result

Andrew CUSHION

Andrew CUSHION

Andrew Dean CUSHION

Andrew D CUSHION

Andrew Dean Gerald CUSHION

Andrew D CUSHION

Andrew Dean Gerald Arnold CUSHION

Andrew D CUSHION

  • Suggested answer
    Microsoft Profile Picture
    Microsoft on at
    RE: Want to first and last string in ax 2012

    you can try to use the SQL keyword: split .

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Want to first and last string in ax 2012

    If you look at the standard system and how names are handled, there are separate fields for first, middle and last names. Please follow this same approach in your functionality.

    Then it's also very easy to achieve the result that you need:

    1) Take the value from FirstName field

    2) Take first character from MiddleName field

    3) Take the value from LastName field.

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Want to first and last string in ax 2012

    Your problem is caused by a wrong data model. You're violating the first normal form by not having atomic values in the name. Consider fixing the model, rather than building workarounds in code.

    If you can't fix the model, take the string and split it to words, e.g. by strSplit(name, ' '). Then take the first and last ones and if the number of words is higher than 2, take the second word and extract the first character by subStr().

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans