754
Views
12
Comments
String Split in Reactive
Question

I am building an app in reactive. The parameter that will be split named scan

Unfortunately the additional results are null

any idea to get the parts of the scan text variable?

2021-09-06 15-09-53
Dorine Boudry
 
MVP

you are not sharing the value from scan, that's crucial for us to help understand what's going on

UserImage.jpg
George M

The scan value is the 100,1994,677739

2021-09-06 15-09-53
Dorine Boudry
 
MVP

that should work, i meant, show it in your debug window, i can see both an input variable 'CodeScanned' into your action and a local variable 'scan' in your screen, are you sure scan has the intended value at the point where you do that StringSplit

2025-02-10 17-24-13
Arun Rajput

Hi @George M ,

It should show split list as your logic seems correct.

If possible can you please share oml file so I can check what going wrong

Thanks

Arun

UserImage.jpg
George M

You may find it attached.

BarcodeScanner.oml
2025-02-10 17-24-13
Arun Rajput

Hi @George M ,

I checked your code, I would suggest use String_Split client action from Reactive Utility Component  instead of using String_Split server action. It works fine and faster than string_split server action.

Please find component link below:

https://www.outsystems.com/forge/component-overview/1730/reactive-utilities#:~:text=A%20group%20of%20multiple%20utilities,side%20to%20the%20client%2Dside.

Thanks,

Arun Rajput

2021-10-09 07-57-44
Stefan Weber
 
MVP

Try to output one of the variables on your screen. It should evaluate the real result then. Debugging server actions called from a client action can be weird, but the rule of thumb is that results from server actions called from a client action are only evaluated when they are used somewhere on the screen.

You are splitting a string with a server action, which causes an unnecessary roundtrip. Unfortunately, there is not built in one but you can create your own.

Create a new client action String_Split with two input parameters both of type text.

* TextToSplit

* Separator

Add an output variable List of type List of Text.

Inside add a Javascript widget

Note the input parameters TextToSplit and Separator

The Output parameter ResultArray has a type of text.

The code splits the text with the given separator. The resulting Javascript Array is then stringified and returned (this is needed as you cannot return a list of text from a javascript element).

After the Javascript widget add a DeserializeJson element

This on deserializes the stringified array to a List of Text.

Last assign the result of DeserializeListText to the client actions output parameter

The whole flow


You can add that function to a library for better reuse. Using clients actions in client actions are also easier to debug.

Best

Stefan

2023-03-29 07-57-22
Kiruthika Balasubramanian

Hi @Stefan Weber

May I know what is the datatype for "List" Output Parameter. 

Thanks,

Kiruthika.


2023-03-29 07-57-22
Kiruthika Balasubramanian
2021-06-03 11-03-21
Anubhav Rai

Hi George,

I saw your OML but there were a lot of dependencies because of that I am not able to run your code.
As per your screenshots, it looks correct, there might be some issue with your barcode scanner output.
But anyhow I am attaching my OML for your reference. 
In a simple implementation, it is working fine, I tested with your provided value.

Regards

StringSplit_Test.oml
2022-07-14 13-58-54
Ridhima Shewani

Hi George,

Please check attached oml

Hope it will help you!


Regards

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