Solved

Dynamic messages

  • 17 February 2022
  • 5 replies
  • 118 views

Userlevel 2
Badge +4

Hi,

Is it possible to add dynamic messages to a message with only 1 parameter?
 

What I have:

  1. A simple popup warning message with 1 parameter in Translations tab

 

  1. Using a control procedure to send dynamic message content to display

 

  1. What I get

If I remove the parent text tag then I only get the first column translation and the rest is ignored which is not what I want.

Is there any way of making this work?

-Thanks

icon

Best answer by Erwin Ekkel 17 February 2022, 16:21

View original

This topic has been closed for comments

5 replies

Userlevel 6
Badge +16

The col tag needs to be outside the text container and needs to have it’s own parameter so in this case you would need {0}{1}{2}

Here is an example for a parameter a column name and another parameter. 

set @xml = concat('<text>', @stock,'</text>
                               <col tabid="address" colid="street" transl="grid"></col>   '
                               ,'<text>', @art_number, '</text>')

Userlevel 7
Badge +23

Adding to what my colleague said, you can also force the parameters to be on a newline by editing the Message translation in the form, then typing:

{0}
{1}
{2}

Forcing a newline can be done by using the keyboard shortkey: Alt+Enter

 

Userlevel 2
Badge +4

I added the necessary parameters and it works great!

But now my issue is that I can only this message if I have 3 parameters to send through. I would’ve liked if I could specify one parameter in the message itself to keep it general. This way I could send a nested message as parameter via the control procedure and not be limited to 3 parameters.

Is there a way to achieve this?

Userlevel 7
Badge +23

You can attach one XML tag like <text> or <col> to one parameter like {0} and {1}. What you can do is append the text together into one parameter like so:

declare @msg_text varchar(100)
select @msg_text = '<text>' + @text_1 + @text_2 + @text_3 + '</text>'

This will then show the three texts together in 1 parameter. You can add these to your texts to for newlines:

  1. Carriage return&#xD;
  2. Line feed&#xA;

Do keep in mind that the texts cannot contain any characters XML doesn't support, like the character &. These characters need to be replaced. For example:

  • ' should be replaced with &apos;
  • " should be replaced with &quot;
  • & should be replaced with &amp;
  • < should be replaced with &lt;
  • > should be replaced with &gt;
Userlevel 2
Badge +4

I was hoping for the ability to use multiple XML tags as one parameter (nested), but I guess I can still make it work with the above suggestions. 

Thanks!