284
Views
10
Comments
Solved
Add a single quote to a text string

Hello,


I have a problem wanting to send a quoted string. I wanted to add a variable between quoted text to send to a service I have. Can anyone help me? I leave an example.

Regards, 

Jorge Rodrigues

2021-09-30 18-38-59
Nuno Ricardo Rodrigues
Solution

Hello Jorge again,

It´ s the same think in Tradicional and Reactive, you should use double quotes, for example like this:

"""" + VarTXT + """"

Hope it helps,

Nuno R

2019-12-06 08-26-53
Jorge Rodrigues

Hi Nuno,


I tried that way and it didn't work.

Regards, 

Jorge Rodrigues

2021-09-30 18-38-59
Nuno Ricardo Rodrigues

Hello @Jorge Rodrigues ,

The example that you give in the begin works :).

This new one I think is a different case, can you share an OML?

Best Regards,

Nuno R

2019-12-06 08-26-53
Jorge Rodrigues

I was doing something wrong, you were right Nuno. Thank you very much.

2021-09-30 18-38-59
Nuno Ricardo Rodrigues

Hello @Jorge Rodrigues ,

It´´´ s Tradicional or Reactive?

Best Regards,

Nuno R

2021-09-30 18-38-59
Nuno Ricardo Rodrigues
Solution

Hello Jorge again,

It´ s the same think in Tradicional and Reactive, you should use double quotes, for example like this:

"""" + VarTXT + """"

Hope it helps,

Nuno R

2019-12-06 08-26-53
Jorge Rodrigues

Hi Nuno,


I tried that way and it didn't work.

Regards, 

Jorge Rodrigues

2021-09-30 18-38-59
Nuno Ricardo Rodrigues

Hello @Jorge Rodrigues ,

The example that you give in the begin works :).

This new one I think is a different case, can you share an OML?

Best Regards,

Nuno R

2019-12-06 08-26-53
Jorge Rodrigues

I was doing something wrong, you were right Nuno. Thank you very much.

2021-09-28 18-45-54
Frederico Arriaga

Hello @Jorge Rodrigues,


Nuno already said it. I'll add if you want just a single quote around the text, do the following:


"'" + VarTXT + "'"


Best,

Frederico

2019-12-06 08-26-53
Jorge Rodrigues

Thanks for the time available, but Nuno's answer was just what I wanted.

2021-10-04 02-42-50
Merliny

Hi,

if you want the result like this "VarTXT", then you can use this """"+VarTXT+"""", no need the backslash, such as belows:


2019-12-06 08-26-53
Jorge Rodrigues

Thanks for the time available, but Nuno's answer was just what I wanted.

2023-04-14 11-47-10
Samuel Frade

@Jorge Rodrigues , to add a single quote (or in your case, a double quote for HTML attributes) within a string in OutSystems, you need to "escape" it.

Here's how it works:

  • OutSystems uses quotation marks (") to define the start and end of a text string.
  • If you want to include a quotation mark inside the string, you can't just type it directly because OutSystems will think it's the end of the string.
  • To fix this, you use """" (four quotation marks in a row). This tells OutSystems to treat the inner two quotation marks as a single literal quotation mark.

Example from my code:

"<p style= " +""""+ " display: flex;justify-content: center;" +""""+ ">" 

  • "<p style= " starts the HTML style attribute.
  • +""""+ adds a quotation mark (").
  • " display: flex;justify-content: center;" is the style value.
  • +""""+ adds another quotation mark (").
  • "> closes the style attribute.

In short, use """" whenever you need to insert a quotation mark within a string in OutSystems.

Debugging:
This was what I have in the Assign:

"<p style= " +""""+ " display: flex;justify-content: center;" +""""+ "> 
   <img style= " +""""+
     display:" +""""+ "block;width:200px;height:200px;display:inline-block;" +""""+
     " id=" +""""+ "base64image" +""""+ 
     " src=" +""""+ "data:image/png;base64, " + EncodeHtml(BinaryToBase64.Base64) + " " +""""+ "> </p>" 

this is after the Assign:

<p style= " display: flex;justify-content: center;">
  <img style= "
      display:"block;width:200px;height:200px;display:inline-block;"
      id="base64image"
      src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...">
</p>




Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.