cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Replacing carriage return and line break in a string

I am pulling in a field from a database table through a SQL Server connection that contains all the fields that populate a dropdown - they are separated by a carriage return and a line feed.

 

My hope is if there is a way to translate a SQL statement like REPLACE(REPLACE(field, CHAR(10), '*'), CHAR(13), '*) which would change them into ** between the dropdown items and then do a split function in PowerApps to get a table of the items to go into the dropdown.

 

I am coming at a loss on how to approach and accomplish however...

1 ACCEPTED SOLUTION

Accepted Solutions
Meneghino
Level 10

Re: Replacing carriage return and line break in a string

Start looking at this:

https://docs.microsoft.com/en-us/powerapps/functions/function-split

 

May work with Char(13) and/or Char(10) as separator

3 REPLIES 3
Meneghino
Level 10

Re: Replacing carriage return and line break in a string

Start looking at this:

https://docs.microsoft.com/en-us/powerapps/functions/function-split

 

May work with Char(13) and/or Char(10) as separator

Anonymous
Not applicable

Re: Replacing carriage return and line break in a string

Thank you, I saw the split part, but wasn't sure if PowerApps recognized line feeds and carriage returns - didn't think to look up if the same Char function existed..... again thanks!

Highlighted
degvalentine
Level: Powered On

Re: Replacing carriage return and line break in a string

Here's a solution without using a separate variable, but is a bit uglier. Depending on your situation, might be better.

  1. encode the content
  2. replace newline with a new delimiter
  3. decode the content
  4. split on the new delimiter

In the example, I use "outputs('Compose')" as the content you want to split and a tilde as the new delimiter.

split(
  decodeUriComponent(
    replace(
      encodeUriComponent(outputs('Compose')),
      '%0A',
      encodeUriComponent('`')
    )
  ),
  '`'
)

You can find do this with windows-style newlines (CRLF), too: "%0D%0A". Here's a link to the W3 School's table of url-encoded values.

 

Edit: just noticed @FlowNick found this same solution a long time ago.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 162 members 5,181 guests
Please welcome our newest community members: