How to configure the IF node when no Calendar Event is found

I am using the Google Calendar Get All Node. I am searching to see if a calendar event has been made in Google. If it was, I want to edit the details. If no event was found, I want to create a new event.

Here is how I have my Google Calender node set up. I think I have it working, at least when I try to test it, it seems like it works.

Event Found

No Event Found

Here is where I am not sure how to set up my IF node. I am hoping someone can help me with this issue. I have searched google, the community and even asked ChatGPT but so far nothing is working.

I am sure its something simple, but as I am brand new to n8n, I am still trying to learn how this setup works.

Thanks!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

So it seems like more testing, the Google Calendar node has changed. From other topics on it, there used to be fields you could insert search criteria into. Now the “query” field seems like it only searches the description field in Google Calendar. If only finds my event if I put all the stuff in there. It doesn’t actually look at the event date or event title fields.

Does anyone know if this has changed? Or how I can search these other fields to find my event.

@jlhsolutions , in the settings of the node where you check the events enable “Always Output Data”. Then in IF node you can check if any item exists.

image

@ihortom Ok I enabled that setting, but I think my Google Calendar Node isn’t working properly because it’s not finding events that it should be seeing.

Here are my Google Calendar Node settings

It shows nothing on the right side now. But I have an event on that date with the title as shown in the next screenshot.

I have been trying to figure out why it’s not seeing it, but I think it’s only searching the description field, not the title, date, etc. I can’t seem to find anything that talks about how to change this.

Any ideas?

Ok, it seems like part of the issue is time. The event is listed in EDT, but my calendar is PDT. So now I need to convert the time. I have tried multiple variations of the code in the code node to convert time, but nothing is working.

I keep making strides in this but I also keep hitting road blocks.

@jlhsolutions , I would remove the date from the Query box (leave just the name). The node offers to use the Date in the Options instead. You have “After” and “Before” in your disposal.

image

Yes, I have been playing with the After and Before Settings today. I think the issue is the time of the event is listed as EDT, but it’s shown as PDT because I live in a different time zone. So I need a way to convert this but I can’t seem to find code that works. I have had ChatGPT write many many different versions, but all of them error out as its trying to use moment-timezone or Moment.js and as I’m using the cloud version for now, I don’t have these libraries.

Google Node Settings

Google Event - Pacific Time

I even tried creating a code node that would convert it but I haven’t been successful with that either.

If I move the event 3 hours in the future, it will find it, but then its at the wrong time, so that doesn’t help me because the event is saved for the wrong time.

Event found after time changed to 3 hours later.


@jlhsolutions , the problem is you are using string representation of the date rather than the date value. Switch to Luxon object DateTime and specify the timezone you need. For example, {{ DateTime.fromSQL($json.body.event_start_date_time).setZone('America/New_York') }}.

Ok, I am getting closer. When I put the formula in there, this is what I see. The times have adjusted 3 hours into the future of what they were.

When I change it to Los_Angeles, it is the same time it was at, but its still 3 hours into the future.

The time should be 5pm Pacific, 8pm Eastern. Not 8pm Pacific, 11pm Eastern as its currently calculating.

Any suggestions on this?

@jlhsolutions , what time zone do you have set up for your workflow? You can check it from Settings menu.

As your incoming start_time and end_time come without the time zone values, it is considered to be local to your workflow (your workflow time zone). Any usage of setZone() will be adjusted from there.

When I change it to Los_Angeles, it is the same time it was at, but its still 3 hours into the future.

Makes sense, as the difference between New York and Los Angeles is 3 hours.