Delete Tasks Errorneously loaded tasks

Hi @diana,
Is there away we can delete some tasks that are being displayed as a result of an error in date format?
I noticed that expected date format for due date is yyyy-mm-dd, if date is not in this format, then when you call this function getDateISOLocal, the current system date will be returned as the task due date.
This results into the tasks being displayed daily/indefinitely hence negatively affecting the intended workflow.
I’ve dropped the report that has the wrongly formatted dates but unfortunately this has not resolved the problem.
Any insights on how this can be resolved.
Thank you.


Hi @ewafula

Tasks will disappear (get cancelled) when their appliesIf, applied to current context, returns false. That will depend entirely on your task definition. Tasks will get recalculated on relevant user actions, for example editing the relevant contact, adding or editing a report that refers to that contact, etc.

For my curiosity, is it possible to share the task definition that produced this issue?

Hi @diana,
Here is my task definition
name: ‘htn.visit’,
title: ‘task.htn_followup.visit’,
appliesTo: ‘reports’,
appliesToType: [‘cht_profile’],
appliesIf: function (contact, report) {
// only if participant is scheduled for home visit
let homevisit = false;
if (getField(report,‘lasthtnnextvisitlocation’) === ‘2’) {
homevisit = true;
return homevisit && getField(report, ‘lasthtnnext_appdate’) && isAlive(contact);

resolvedIf: function (contact) {
  //(refused or migrated) and cleared tasks 
  if (isHTNTaskMuted(contact)) { return true; }
  if(isAlreadySeenAtClinicHTN(contact)) { return true; }


actions:[{form: 'care_htn'}],
events: [{
  id: 'next htn-followup visit reminder',
  start: 3,
  end: 30,
  dueDate: function(event, contact, report) {
    return getNextHTNAppointmentDate (event, contact, report);


As I noted the error is being caused by the due date.
Thank you.

Thanks for sharing @ewafula

This seems like a simple definition, I think your task should disappear if you delete the cht_profile form that generated it. If it does not, I would try to make an edit to the contact document that the report was about.

If the dueDate calculation is indeed the cause of your problem, I suspect the steps to fix is are:

  1. Correct the dueDate calculation in your javascript code.
  2. Test the fix by observing task behavior on a local CHT instance
  3. Deploy the fix to your production CHT instance
  4. Have user sync the fix

Apologies if I’ve misunderstood something and the error is indeed in the contact form as suggested. Once the fix syncs to the user’s phones, you should see the task appear correctly. I suspect you shouldn’t have to modify any task documents or reports to correct this problem.

1 Like

Thank you @kenn and @diana,
The problem is not on the task definition. The task is correctly defined but the error occurs on the date conversion.
The problem is on the report.