Select to view content in your preferred language

Extract data from repeat

547
1
Jump to solution
05-19-2023 10:53 AM
abureaux
MVP Frequent Contributor

I am pulling a blank here.

I have two repeats: Deploy, Retrieve

Deploy has: UID plus a bunch of other fields.

Retrieve has: UID plus a bunch of other fields.

What I need is: User enters a bunch of data into Deploy and submits. At a later date, they return to site, go to Inbox, grab the previous submission. User scans a barcode that enters a unique number into Retrieve's UID field which pulls data from the Deploy repeat.

How would I go about pulling data from this repeat?

I can do this by referencing position(..) quite easily; but this is too cumbersome. I can also do something similar pulling data from the Feature Layer; but the solution needs to work in an offline environment (This may also restrict us from using Java--users have accounts, but no internet in the field). 

0 Kudos
1 Solution

Accepted Solutions
abureaux
MVP Frequent Contributor

I was able to use Javascript to achieve what I want here. I don't know if this can be completed without JS, and I am not claiming that this code is as efficient as it should be, but it gets results!

function myfunction(f, ad) {
	let finder = f;	
	let dataset = ad.split(',');

	const myArray = dataset.indexOf(f) >= 0; 
	const position = dataset.indexOf(f);

	return position;
}

Going off my repeats above, I use join() to create a comma separated list of UIDs for my Deploy repeat (for the sake of this example, lets name it deploy_join)

abureaux_0-1687533213283.png

Then, I created two calculates: index_js, and index_js1

index_js uses the pulldate() generated by S123: pulldata("@javascript", "functions.js", "myfunction", ${<f>}, ${<ad>})

  • ${<f>} = A barcode question in my Retrieve repeat (Let's call it rtv_barcode)
  • ${<ad>} = deploy_join

At this point, the JS is working. If you scan a barcode, it will search the join() for that number, and return the index of that number in the string. The problem is, when JS starts counting, it starts at 0. But for the final step, I needed it to start counting at 1.

index_js1 is simply index_js + 1.

abureaux_1-1687533267789.png

Now I have an index that S123 can use. I extract all of the information I want from the previous repeat with the built in indexed-repeat() function:

abureaux_2-1687533684107.png

 

 

View solution in original post

0 Kudos
1 Reply
abureaux
MVP Frequent Contributor

I was able to use Javascript to achieve what I want here. I don't know if this can be completed without JS, and I am not claiming that this code is as efficient as it should be, but it gets results!

function myfunction(f, ad) {
	let finder = f;	
	let dataset = ad.split(',');

	const myArray = dataset.indexOf(f) >= 0; 
	const position = dataset.indexOf(f);

	return position;
}

Going off my repeats above, I use join() to create a comma separated list of UIDs for my Deploy repeat (for the sake of this example, lets name it deploy_join)

abureaux_0-1687533213283.png

Then, I created two calculates: index_js, and index_js1

index_js uses the pulldate() generated by S123: pulldata("@javascript", "functions.js", "myfunction", ${<f>}, ${<ad>})

  • ${<f>} = A barcode question in my Retrieve repeat (Let's call it rtv_barcode)
  • ${<ad>} = deploy_join

At this point, the JS is working. If you scan a barcode, it will search the join() for that number, and return the index of that number in the string. The problem is, when JS starts counting, it starts at 0. But for the final step, I needed it to start counting at 1.

index_js1 is simply index_js + 1.

abureaux_1-1687533267789.png

Now I have an index that S123 can use. I extract all of the information I want from the previous repeat with the built in indexed-repeat() function:

abureaux_2-1687533684107.png

 

 

0 Kudos