convert list text to text

convert list text to text

  

Hi Team,

I have a requirement of converting text list to text.

I tired using foreach loop to append list values in the variable, but using foreach is not convenient as it gives duplicate values. (refer: Var1 assignment)

Also please note i cannot use stringJoin  action as my list is of type text and not text record list.

( For StringJoin action Required type is- Text Record list)

Kindly assist. Many Thanks!

Hi,


What is the source of list.I mean from where u get list of text values.


Thanks!

JitendraYadav wrote:

Hi,


What is the source of list.I mean from where u get list of text values.


Thanks!

Hi, I've made a local variable of datatype 'Text List'.


Just use appendall to create a list of string from list of records and then Sting_Join should work.


https://success.outsystems.com/Documentation/11/Reference/OutSystems_APIs/System_Actions#ListAppendAll

Gurpreet Bhui wrote:

JitendraYadav wrote:

Hi,


What is the source of list.I mean from where u get list of text values.


Thanks!

Hi, I've made a local variable of datatype 'Text List'.



Yes but from where u get the data to store in text list.

Besides it could be solved better, i was wondering about the var1 assignment.

imho it should be more like.

var1 + if(var1="","",",") + var2.current


JitendraYadav wrote:

Gurpreet Bhui wrote:

JitendraYadav wrote:

Hi,


What is the source of list.I mean from where u get list of text values.


Thanks!

Hi, I've made a local variable of datatype 'Text List'.



Yes but from where u get the data to store in text list.

Hi, PFB. This will help-

J. wrote:

Besides it could be solved better, i was wondering about the var1 assignment.

imho it should be more like.

var1 + if(var1="","",",") + var2.current


Hi, This does not work :( as Var1 is always appended in the Var1 in foreach loop which gives duplicates.

i.e on first iteration- 1,2

on second iteration- 1,2,3


Gurpreet Bhui wrote:

J. wrote:

Besides it could be solved better, i was wondering about the var1 assignment.

imho it should be more like.

var1 + if(var1="","",",") + var2.current


Hi, This does not work :( as Var1 is always appended in the Var1 in foreach loop which gives duplicates.

i.e on first iteration- 1,2

on second iteration- 1,2,3


Hi,


For removing duplicates use if widgets and put condition to check current value index in saved text data variable.

Note. before iteration use list sort on text value so that all the values come into sorted order.

Thanks!


Hi,


I would suggest you use 


String_join (Concatenates all the strings in a List, yielding a single string. The individual elements are separated, in the resulting string, by the string Separator.)




Hope this helps.


Atul

Hi Gurpreet,


Depending on the amount of data you might consider using StringBuilder which is said to be considerably more performant than concatenate it with '+ ","' pattern. You can find information here how to use it.

Regarding the removal of duplicates in the list, if you're using P11, the ListDistinct action should already be available as the idea for this functionality is already implemented.


Hope this helps.

João

Hi All,


As suggested i tired using StringJoin and for this changed my variable to datatype of type- TextList


and now for the ListAppend Action, i am not able to append the desired element.

Tired with both tableRecords and ListRecords


Please help!!

This is getting worse!!

Many Thanks!

Hi Gurpreet,


Actually you don't need ListAppend or LocalVariable for this implementation. You can directly pass your tableRecords or ListRecords to String_Join and get list as text. See screenshot below.


 

Hope this helps

Atul