Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Removing blank lines from a string

Posted on by 35

I have users who are tapping enter twice at the end of an address field and when I am concatenating the street with the city I get blank lines in the address which is causing an issue with checks. I was attempting to fix it with replacing line breaks but couldn't get the desired result. Is there a way to scan each line and remove it if it is doesn't have any text?

*This post is locked for comments

  • Korbrm Profile Picture
    Korbrm 35 on at
    RE: Removing blank lines from a string

    Thank you!

    Changed it around a little bit and added the loop for when they eventually add 2 carriage returns.

    while (substr(Street, strlen(Street),1) == "\n")

       {

           Street = substr(Street, 1, strlen(Street) -1);

       }

  • Verified answer
    DaxNigel Profile Picture
    DaxNigel 2,572 on at
    RE: Removing blank lines from a string

    This is a common problem with user pressing carriage return at the end of the address.

    If you want to look if the last two characters in the street address is a carriage return then use the following:

    if(substring(Street, len(Street) - 2, 2) == "\r\n")

    {

       street = substring(street, 1, len(street) - 2));

    }

    You need to check, as I am not on a system at the moment, but you might need to use 1 character and \n rather than \r\n, can remember if it uses both or just \n.

    This will of course only check the last characters for returns. If the user pressed it multiple times, you might want to run a loop to check you get them all.

    Please mark this as an answer if you found the information useful.

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