cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MidwayC11
Helper I
Helper I

How to add double quotes to a string

Hi there, 

 

I'm getting a bunch of string values from a stored proc from SQL Server, I'm just trying to add double quotes to a couple of strings from the result set. 

let's say I'm getting a string like so; TEST so to this string I'm trying to add double quotes like this "TEST".

 

If I add the double quotes in the source, so the string would come in as "TEST", flow just add more quotes to it like this """TEST"""

 

Thanks for your help!

 

13 REPLIES 13
cchannon
Super User
Super User

How are you trying to use this string that "flow just add more quotes" and did you deliberately put three sets of quotes on each side of that second example, or was it supposed to be 2? That is, did you mean """TEST""" or ""TEST""?

This is an example what I'm trying to do;

MidwayC11_0-1627776223083.png

 

I'm trying to just add double quotes to strings in the Compose with replace, when I run the flow nothing gets added to the string in the Compose 2 strings.

 

1

Yeah, that is not how Replace works. It takes a literal character search string, finds that string everywhere in the input and replaces it with a literal character replacement string.

 

If you're trying to wrap the entire string in one set of quotes, you just want to have a new Compose that is something along the lies of

'"' + Compose1 + '"'

(or you can use string append operator, but the addition character should work fine for string building)

 

If you're trying to wrap each member of the comma separated list in quotes, you'll need to be slightly more elaborate. Something along these lines this ought to do the trick: 

'"'+ Replace(Compose1, ', ', '", "') + '"'

 

thanks for replying to my post. somehow I'm trying to build that string taking your example, but somehow the 

expression is complaining that's an invalid expression.

 

Yes. I think maybe you should consider some basic string manipulation instruction or courses. You should get an understanding of what a string is and how you work with it before you continue.

Thanks but I know what a "String" is, I'm trying to get some help on how to manipulate it in power automate that seems to be finicky with strings. Manipulating strings with SQL is easy or C# as well but this is my first time that I'm trying to manipulate string with this tool, that's why I'm looking for some help.

Sorry to have offended. I think I confused your reply with a different email notification.

 

OK, so yes, you will get 'invalid expression' message from pasting my suggestion because I just wrote it off the top of my head. I am not in your flow, therefore I do not have the object model of your flow.

 

You need to write something along those lines in your flow, so:

 

  • IF you start with Test, Test and want "Test, Test" then use
    • '"' + 'Test, Test' + '"'
  • IF you start with Test, Test and want "Test", "Test" then use
    • '"'+ Replace('Test, Test', ', ', '", "') + '"'

Obviously, you need to put your parameter name in there instead of Test, Test

All good, none taken here. Was just trying to clarify things. Thanks so much for your help, I'll give this a try!

Hi there, 

 

So when I write the 

  • '"'+ Replace('Test, Test', ', ', '", "') + '"' into the Expression field, it keep saying that's an invalid string. I tested with SQL and its perfectly fine. 

MidwayC11_0-1628041631636.png

 

Yeah, sometimes PowerAutomate prefers that you actually use the concat method instead of just the addition operator. Here, I did a quick proof, so this syntax should work fine for you (you will probably have to replace the param name, but it should otherwise work) 

cchannon_1-1628079820357.png

 

concat('"', replace(outputs('Compose'), ', ', '", "'), '"')

 

 

thanks for your replies to my post. still have an issue with this, I will illustrate below;

 

So like I said as the beginning of this post, I'm bringing data from a stored procedure from SQL Server like this; both fields are strings in SQL Server.

 

MidwayC11_0-1628106224092.png

So from these values, I want to build a CSV table; without adding anything to the items in the Expression, they comes out like this; Body without any quotes

MidwayC11_1-1628106424945.png

Now I just want to add double quotes to both strings, concat( '"', item()?['TEST'], '"') and concat( '"', item()?['TEST1'], '"'), they come out like this; 

MidwayC11_2-1628106694607.png

They come out with triple double quotes at each side of the strings?? would you know how to get rid of the extra 2 double quotes at each side of the strings?

 

 

MidwayC11
Helper I
Helper I

so anybody?

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,281)