Applying skip logic in Data set

Dear Community,
@Gassim, is there a way skip logic can be applied in data sets while entering data? or this is only available on tracker program? another option would be to apply data validation rules, however I wonder if there is a way to validate qualitative data in data set,

Here I mean let for example say that number of students with disabilities will be entered only when the respondent says they have some,

ex: Question 1: do you have students with disabilities at this school?(Yes/NO)
Question 2: if yes how many? (Number)

as you can see question 2 depends on question 1

is this something configurable in Aggregate?

Thanks

Pachat

3 Likes

Hi @Pacifique_Hategekima,
When creating a dataset you will need to create a custom form and use JavaScript yourself to control these options because unfortunately, the skip logic and ‘program rules’ are only available in tracker not aggregate, but I saw suggestions in the community to use the tracker anyway!

I wanted to create a JavaScript for you and the community to help with getting started but unfortunately it still needs correction but here’s an example (needs correction so anyone feel free to correct it, thanks!):
It looks likes this:

<table>
	<tbody>
		<tr>
			<th>Test</th>
		</tr>
		<tr>
			<td id="underfive"><input id="dataElementID" name="entryfield" title="Inpatient cases Under 5 years" value="[ Inpatient cases Under 5 years ]" /></td>
		</tr>
		<tr>
			<td><input id="fiveAboveDataElement" name="entryfield" title="Inpatient cases 5 years and above" value="[ Inpatient cases 5 years and above ]" /></td>
		</tr>
	</tbody>
</table>
<script> 
document.querySelector("#underfive").firstChild.value.onchange = function(){
    if(document.querySelector("#underfive").firstChild.value == 0)
    { document.querySelector("#underfive").style.display = "none";}
    }
</script>
2 Likes

@Pacifique_Hategekima,
I worked again on the script above and the following one should work, but I need to tell you that this is at least to demonstrate an idea that will require a lot of work, here’s why? I used css style to hide the fields but then if you change the period to another period the same fields will remian hidden even if they are empty and will require you to refresh! The other issue in question is that this will not work on the android app. Maybe someone with advanced Javascripts skills would be able to solve some of these challenges but it seems that if you really need skip logic, you might want to use it on tracker.

<style type="text/css">.hidden {
display:none;}
</style>
<table>
	<tbody>
		<tr>
			<th>Test</th>
		</tr>
		<tr>
			<td id="underfive"><input oninput="test2022()" id="r6nrJANOqMw-HllvX50cXC0-val" name="entryfield" title="Malaria (Deaths &lt; 5 yrs)" value="[ Malaria (Deaths &lt; 5 yrs) ]" /></td>
		</tr>
		<tr>
			<td><input name="entryfield" value="" /></td>
		</tr>
	</tbody>
</table>
<script> 
function test2022() {
document.querySelector("#underfive").firstChild.classList.add('toHide');
setLogic();
}

function setLogic() {
document.querySelector('.toHide').onchange = function() {
if(document.querySelector("#underfive").firstChild.value == 0){
document.querySelector("#underfive").classList.add('hidden');
}
}
}
</script>
1 Like

this is so cool let me try it in my app and revert.

Thank you

1 Like

Please note that custom forms are not available in Android and therefore the solution proposed will only work for web input :slight_smile:

2 Likes

Yes and it requires a lot of work actually! It might also affect the feature to export reports to PDF files.

Maybe the best option is to actually use Tracker? (:

1 Like