I have a app form .i.e screening_form
In the screening form , there is a variable name “bp1_eq_bp2”
My requirement is , if “bp1_eq_bp2” =“yes” , then only the task should be generated.
The task configuration parameter which controls when tasks get created is appliesIf, you can find detailed explanations about this on the docs site: Understanding the parameters in the Task Schema | Community Health Toolkit resolvedIf is only called after the task gets created. A true response from resolvedIf will clear the task, while a false response will keep it active.
The way your code works now, always returning false when “bp1_eq_bp2” === “no” means that your tasks will stay active for these reports, which is the opposite of what you’re looking for, as far as I understand.
So, i have a code like this but still the task is created for every screening form we fill. and we are getting this error in flhw account but task is generated in fchv account.
Apart from adding appliesIf, I have made other changes to your code:
Identify whether the user is an FCHV by checking the permissions instead of contact.roles. Here, contact represents the patient contact, not the user. When using hasPermissions, please select the permission that is only given to the FCHV role. You can also define custom permissions in your app settings.
Using Utils.getField() instead of accessing the report fields directly.
Removing resolvedIf: Your task configuration should work fine without explicit resolvedIf because of the default resolvedIf behavior. This is optional.
so, our requirement is that we need to create the task only if bp1_eq_bp2, this is the variable defined in our form. and translation key for this variable is “report.screening_form.hypertension_screening.bp1_eq_bp2” And also we need to create a task for fchv only !!! To test it we are changing our date. But we are still getting the task for both FCHV and FLHW and also the task is generated even after selecting no in the form.
For this we have: Utils.getField(report, 'hypertension_screening.bp1_eq_bp2') === 'yes'.
For this, we have: isFCHVUser = cht.v1.hasPermissions(['can_view_tasks_group']);
From a copy of your old configuration that I have access to, this permission is only set for FCHVs. Please adjust it if it is no longer the case. If you don’t have any permission unique to FCHVs, you can add one in your base_settings.json file like this: