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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Removing blank lines from a string

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Verified answer
    DaxNigel Profile Picture
    2,574 on at

    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.

  • Korbrm Profile Picture
    35 on at

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

       }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans