1477
Views
17
Comments
Solved
Text List to Text
Application Type
Reactive
Service Studio Version
11.53.34 (Build 61795)
Platform Version
11.18.1 (Build 37828)

I have an expression which I'd like to set to the joined elements of a text list.

That is, a text list with elements:

["a", "b", "c"]

and the expression I'd like to set as something like:

String.Join(json, ";")

with the resulting expression being = "a;b;c"

I've searched the forums and can't believe there is no way to join a text list without adding additional variables, client actions and server actions (the String_Join).

Anyone know what I'm missing?

UserImage.jpg
Ben Jamin
Solution

Sorry Shubham - I've had to unmark your answer as the solution.  Pre-calculating the join on load and then sending it into the list is creative, but I don't think is the intended way to do it.

The current best solution I've found is that:

  • Acknowledge that OutSystems can't do a join in an expression (or as part of a list iterator)
  • You can however use a list iterator within a list iterator
  • You can have a list iterator output a simple expression in a span (rather than a full row) and can therefore generate text like "a; b; c" without using anything else.

So I think the best practice is probably to use nested list iterators to do a join.

(Obviously if you need the joined data for something other than UI, you'll need to calculate the join somewhere else and use additional variables, client actions, etc...)

2022-08-03 04-32-50
Ravi Punjwani

String_Join from the System module should work.

It accepts a value which should be list of Text, and another parameter is the separator where you can pass your string literal ";" And that would return you the joined string.

String_Join is a server action. Do you want this only as a client action?

UserImage.jpg
Ben Jamin

Thanks - yes I've seen String_Join.

But I can't believe you need a server action for a client function!

That can't be best practice!

2022-08-03 04-32-50
Ravi Punjwani

You can create a small JavaScript function to achieve this. Client action would be ideal if you want to use it on client side only.

UserImage.jpg
Ben Jamin

Thanks.  But you can't access Javascript from an expression.  You would need to create local variables and a client action.

I'm trying to use it as part of a list.  So (afaik) you can't use client action on each list item...

2022-08-03 04-32-50
Ravi Punjwani

You can use this forge component for common utility client actions

https://www.outsystems.com/forge/component-overview/11239/javascript-common-utility

I'm not sure if they are available to use as functions 

UserImage.jpg
Ben Jamin

Thanks.  Yes I've seen there are forge components which can help.  But it is difficult to believe I need to add a third party library to join elements of a text array.

So I'm guessing that the answer is OutSystems does not support a "join" function (like javascript https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join and most other things)

2025-04-17 05-42-16
Ajit Kurane

Hi Ben,

Hope you are doing well.

Please check below thread and there is one sample oml file with demo link and gave another way of achieving the same using for each.

https://www.outsystems.com/forums/discussion/67121/convert-list-of-text-to-text/

Thanks,

Ajit Kurane.


UserImage.jpg
Ben Jamin

Thanks Ajit.  Unfortunately the demo link died many years ago.  And the solution posted involves a client action which iterates over the array - that's not something which can be used directly by a expression.  As I say above, it can't be that difficult to join elements of a text array.

2025-04-17 05-42-16
Ajit Kurane

yes I understood that, Looking for an alternative now.

2021-08-12 05-19-40
Shubham Janbandhu

Hi Ben Jamin,

Hope you are doing well.

I have tried something similar to meet the requirement using another method. Can refer below OML (check "TextString" screen) and let me know if that's help you out.

Sample:

Regards,

Shubham 



Demo.oml
UserImage.jpg
Ben Jamin

Thanks - I appreciate your effort, but that solution uses a client action, which AFAIK you can't use as part of a list.

I've attached the problem I'm trying to solve.  You'll see in the attached that Var3 only shows the ".current" in the list - I need it to join all elements of Var3 to a single string which can be displayed by the expression.


StringListProblem.oml
2021-08-12 05-19-40
Shubham Janbandhu

you almost achieved 90% of your requirement.

If you are appending it to "Expression" use it on screen instead of using Var.current value it is incorrect you will get only a value according to it.

 Regards,

Shubham

UserImage.jpg
Ben Jamin

Thanks - but that will just show "Expression" for each row in the screen list element.  For:

{[
["a","b","c"],
["x","y","z"]
]}

I need it to show:

a;b;c
x;y;z

AFAIK there is no way to run the client action for each row in the screen list.  I'd be very happy to be wrong! 

There needs to be a way to say:

Expression = String.Join(Var3, ";");

and have that evaluated for each row in the screen list.

(I just used var3.current as an example - otherwise it has an error).

2021-08-12 05-19-40
Shubham Janbandhu

I updated the OML according to, in below screenshot you will get the result as per requirement.

For now, I just implement the logic using On Initialize and On Ready, use that logic as per your need and map the TextList with your list. Hope that helps.

StringListProblem.oml
UserImage.jpg
Ben Jamin

You get points for creativity!  And I'll mark it as the solution.  But for others reading this post, this is really just working around a problem with OutSystems.

Thanks for your help.

2021-08-12 05-19-40
Shubham Janbandhu

I'm glad it worked out. 

Thanks.

UserImage.jpg
Ben Jamin
Solution

Sorry Shubham - I've had to unmark your answer as the solution.  Pre-calculating the join on load and then sending it into the list is creative, but I don't think is the intended way to do it.

The current best solution I've found is that:

  • Acknowledge that OutSystems can't do a join in an expression (or as part of a list iterator)
  • You can however use a list iterator within a list iterator
  • You can have a list iterator output a simple expression in a span (rather than a full row) and can therefore generate text like "a; b; c" without using anything else.

So I think the best practice is probably to use nested list iterators to do a join.

(Obviously if you need the joined data for something other than UI, you'll need to calculate the join somewhere else and use additional variables, client actions, etc...)

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