Events New_Value Not Showing For Task Due Dates (NodeJS)

Apologies if this has been answered before, but I wasn’t finding it and I’m stumped.

I’m updating our webhooks to call for more detailed event logs than the hook sends instead of calling for the item itself, e.g. getEventData instead of getTaskData. I don’t know if this is due to me making a silly mistake (which it generally is,) if it’s some kind of bug, or if it was designed like this on purpose:

:point_right:I cannot get event calls to show the new value on changes to a task’s due date.

I’ve got no problem getting the new value on custom_field dates, this is just on the due date for the task. I haven’t tried on a project yet.

Hook Data

{
    "resource": "task",
    "target": *URL*,
    "filters": [
      {
        "resource_type": "task",
        "resource_subtype": "default_task",
        "action": "changed",
        "fields": [
          "start_on",
          "due_on",
          "assignee",
          "custom_fields",
          "name",
          "completed"
        ]
      }
    ]
  }

Event Call

async getEventData(target, sync){
    let eai = eventAPI(), 
        opts = new Object;
    if(sync){
      opts.sync = sync;
    }
    opts.opt_fields="action,change,change.action,change.added_value"
      +",change.field,change.new_value,change.new_value.number_value"
      +",change.new_value.date_value,change.new_value.date_value.date,change.new_value.date_value.datetime"
      +",change.removed_value,created_at"
      +",parent,parent.name,resource,resource.name,type,user,user.name";
    
    return await eai.getEvents(target, opts).then((res)=>{
      return [res.data, res._response.sync];
    }).catch((error)=>{
      if(error.response&&error.response.text){
        let obj = JSON.parse(error.response.text);
        //console.log(obj);
        if(obj.sync){
          return this.reGetEventData(target, obj.sync);
        }else{
          files.errorLog("There was an issue getting event data", error);
          return [false, null];
        }
      }else{
        files.errorLog("There was an issue getting event data", error);
        return [false, null];
      }
    });
  }

Event for Changed Date-Type Custom Field

{
  "parent": null,
  "action": "changed",
  "type": "task",
  "created_at": "2025-02-07T21:08:43.044Z",
  "resource": {
    "gid": *GID*,
    "name": "PC Assignment: Test - Test"
  },
  "user": {
    "gid":*GID*,
    "name": *USER*
  },
  "change": {
    "field": "custom_fields",
    "action": "changed",
    "new_value": {
      "gid": *GID*,
      "date_value": {
        "date": "2024-06-11",
        "date_time": null
      }
    }
  }
}

Event Changed Due Date

{
  "parent": null,
  "action": "changed",
  "type": "task",
  "created_at": "2025-02-07T21:09:52.298Z",
  "change": {
    "field": "due_on",
    "action": "changed"
  },
  "resource": {
    "gid": *GID*,
    "name": "PC Assignment: Test - Test"
  },
  "user": {
    "gid": *GID*,
    "name": *USER*
  }
}

Is there a way to get the value of the new due date from an event that I’ve missed; is this a bug that needs to be fixed; or do I just have to get the task/project to get due dates?

Any guidance would be greatly appreciated!

Hi @Kariah_Petrille,

It’s not possible to get that data in the webhook payload; you’ll have to do an additional call to retrieve it.

From the API docs:

Note that events are “compact” and contain only some basic details of the change, rather than containing the entire resource. We expect integrations to make additional requests to the API to retrieve the latest state from Asana.

Hey @Phil_Seeman,
Thanks for responding. I’m not relying on the webhook post for the data (including the webhook call probably made that confusing, my bad!) I’m reacting to the webhook payload by calling the Events API to get more detailed information about the event.

Get events on a resource

This one allows me to get more information (not compact) about what changed, like the noted custom-field date change. I’ve been able to get the new value on everything I’ve been looking for except for the due date.

*Update: I’m trying to do this in the first place as an efficiency measure. My existing system does make calls to the resource. From the above linked page:

In general, requesting events on a resource is faster and subject to higher rate limits than requesting the resource itself. Additionally, change events “bubble up” (e.g., listening to events on a project would include when stories are added to tasks in the project, and even to subtasks).

Ah, I see now, thanks for the additional explanation!

@John_Baldo @John_Vu Any idea why it’s not returning new_value for a due-date-changed event?

Hi @Kariah_Petrille,

The reason why you are not getting a new_value data back when you change the due date of a task is because the due_at/due_on property of a task is not an Asana resource (i.e., task, project, custom_field, portfolio etc…).

The reason why you get new_value back for when you change a date custom field is because the the due date custom field is an custom field Asana resource.

Since due_at/due_on is a property on a task object and not an Asana resource itself that would explain why you do not get new_value back. This is why in our docs for new_value we say:

Conditional. This property is only present when the value of the event’s change.action is changed and the new_value is an Asana resource.

Another example of when new_value does not get returned, is if you change the name of a task. Since name is a property on a task and not an Asana resource, new_value is not returned

2 Likes

Got it! I didn’t realize that that wasn’t considered an Asana resource. I’ll account for it in the code! Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.