Possible to check which field was updated in a Pipedrive Trigger?

I am trying to set up an automation to create the next activity whenever a previous activity is marked done.

I have configured the Pipedrive Trigger to pick up updates to Activity.
image

Even if I add an IF condition to check if the value of ‘done’ is ‘true’, when I make changes to a done activity, I will have the risk of running this automation again.

So is there a way to execute the workflow ONLY WHEN the status of an activity is updated to Done?

Hi @amit, I hope you’re having a good day thus far?

Our trigger nodes are essentially wrappers around the webhooks from Pipedrive. While these webhooks from Pipedrive don’t tell us what exactly has changed, they do sent through the previous state of the object in question (in this case the activity).

So you can use a simple IF node to check whether the value of a specific field has changed. This example flow demonstrates how to check the done field, but can easily adjusted to check other fields as well:

image

{
  "nodes": [
    {
      "parameters": {
        "action": "updated",
        "object": "activity"
      },
      "name": "Pipedrive Trigger",
      "type": "n8n-nodes-base.pipedriveTrigger",
      "typeVersion": 1,
      "position": [
        450,
        300
      ],
      "webhookId": "decb2d85-6690-4dcd-abed-524f35da43ae",
      "credentials": {
        "pipedriveApi": {
          "id": "21",
          "name": "Pipedrive account 2"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"current\"][\"done\"]}}",
              "operation": "notEqual",
              "value2": "={{$json[\"previous\"][\"done\"]}}"
            }
          ]
        }
      },
      "name": "Has done field changed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {},
      "name": "Has Changed",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        850,
        200
      ]
    },
    {
      "parameters": {},
      "name": "Has Not Changed",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        850,
        400
      ]
    }
  ],
  "connections": {
    "Pipedrive Trigger": {
      "main": [
        [
          {
            "node": "Has done field changed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has done field changed?": {
      "main": [
        [
          {
            "node": "Has Changed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Has Not Changed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hope this helps! Let me know if you need any help with this :slight_smile:

This is great. It worked. Thank you so much.

I am new to n8n, so sorry for my ignorance, but how can I use the code you shared with the solution?

1 Like

Sorry for not being clearer on that - you can essentially just copy the JSON code block I have shared and then paste it right into your n8n workflow (described in more detail at Workflow | Docs).

You then wouldn’t have to build it yourself, just pick the right credentials on the Pipedrive Trigger node and you’re good to do. Hope this makes sense!

1 Like

It does.
Thank you so much.

1 Like

Hi everyone!
I was able to implement the complex workflow that I had set out to do when trying out n8n.
I used @MutedJam’s suggestion to compare previous versus current data to see which field was updated.

A majority of tasks fail the first condition (Activity Marked Done? → Do nothing), where the activity is updated, but the update is not in the form of activity done status. This works fine, but my query is about what counts as a workflow execution. Because in this case, even if the rest of the flow, which this is designed to do, doesn’t execute, it is still counted as execution and towards the quota of my plan.

Am I doing something wrong? Or is my expectation to not count this as an execution unfair? :smiley: