Add string to another string multiple times
Application Type
Traditional Web

I'm looking for a simple method that allows me to repeat some string n times. Thanks

mvp_badge
MVP
Solution

Hi Nannu,

Yes! You can do it in the same way of the example, with an 'IF', for each or even recursive action, here is the example with the 'IF':



It will result on it:


Also attaching the module with the changes.

Hope it helps,

Cheers and Regards,

RR :)

ReplicateString.oml

Hello @Nannu,

You can achieve this with an 'If' widget and loop over 'n' times.
(Edited: Removed the oml I had attached earlier)

Regards,

AJ

Hi Aj,

I am trying to avoid the for loops. I am looking for a simple function. For example REPLICATE() function in SQL.

Thank you for your time.

mvp_badge
MVP

Hi Nannu,

If you want to use the SQL function inside an advance SQL element you can do it.

However if you want to use it on Server Side or Client Side on your OutSystems code, there is not a built-in function for that, and you will need to do your own.


Theres is no way that I see for you to create it without iterating 'n' times somehow.

You can use for example:

- a recursive action, 

- an if 

- a for each.


The easiest way is the 'if' like AJ said, something like this:




I was not able to download AJ Module so Im also attaching the one I used for this print screen.


Hope it helps,

Cheers and Regards,

RR :)

ReplicateString.oml

Hi Raphael,

I am trying to implement this logic in server action. Basically, I am looping through thousands of records and concatenating a string from different fields of the table. During this process, I need to perform certain operations on the field value to get the desired output. I am using String builder for this.

Thank you for your time.

mvp_badge
MVP

Hi Nannu,

That is perfect!
Well done.


If you are creating a very large string, using lots of smaller strings, this is the best way to do it.
Check here some guidance to use this pattern.


If you have any problem with this let us know.


The module I attached should not be used in this use case, it should be used only for small strings concatanations .

Cheers and Regards,

RR :)

Hi Raphael,

is there any way to add a string to another string multiple times with string builder?

Thanks

mvp_badge
MVP
Solution

Hi Nannu,

Yes! You can do it in the same way of the example, with an 'IF', for each or even recursive action, here is the example with the 'IF':



It will result on it:


Also attaching the module with the changes.

Hope it helps,

Cheers and Regards,

RR :)

ReplicateString.oml

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