QR Code returnes many values in one string. How to split the string.

Christof Brockh
Tera Contributor

Hi community,

 

I am currently configuring the mobile agent app.

Create Assets from QR Code is one of the functions my customer wants.

I does actually work well.

 

But: The QR Code holds 5 values. The scan returnes these values all concatinated in one string.

I created a field on the input form screen called qr_code with the type barcode.

After the scan, the value of the field is the concatinated string, which is of course hard to read.

 

What I want to do is:

Split the String along the ("\n") and distribute the values on 5 input fields on the form, so the user can check the values before creating the asset.

 

Do you know how I can achieve this?
I basically want to run a function right after the scan process finished and update the input form screen with this function.

I tried to add a function with a action item to the parent screen, but it does not run after the scan, but much later.

 

I am clueless if it is possible at all, and how I could do this?

Any help would be appreciated.

 

best regards

Chris

 

 

 

4 REPLIES 4

_Gaurav
Kilo Sage

HI @Christof Brockh 

You can use the split method, for instance

var stringText = "Your response getting after scanning";
var myArray = stringText .split(" ");
var word = myArray[0];

Here, var word will contain "your" similarly myArray[1] will contain "response".
You can use and split the string.

Please mark this as helpful if this resolves your query.
Thanks!

AshishKM
Kilo Patron
Kilo Patron

Hi @Christof Brockh , 

Can you please share the one example of that concatinated value, Is there any delimiter in that value.

If there a delimiter, then you can use string split() method to split those values and store in arrayList.

If there is no delimiter, base on QR code length, you can use string substr() method to get values in arrayList.

 

Let us know which one applicable in your case.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi

There is a delimiter ('\n').

The question is: How and where to execute the function in context of the now mobile agent app without saving the string to any backend table.

You can try the below code with a sample qr_code string in background script to check/test this split process and there determine, where you need to use this code logic. You dont need to save any value in database table but you need to iterate the arrayList to get those value for displaying or using in running business process.

 

var barCodeArray = qr_code.split('\n');
for(var i=0;i<barCodeArray;i++){
       gs.print("Bar Cade="+barCodeArray [i])
}

 

-Thanks,

AshishKM

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution