I’m sorry to hear that you’re having an issue with the Google Calendar Create Event app. To better assist you, can you please provide more details about the workflow you’ve set up and the specific trigger or action you’re using? This will help me understand the issue and provide a solution.
To create a Google Calendar event with the correct ending date and time based on the user’s input, you can use the following code snippet in a Pipedream code step. This code assumes you have the starting date, ending date, and starting time from the Google Form trigger. ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google”, }, startingDate: { type: “string”, label: “Starting Date”, }, endingDate: { type: “string”, label: “Ending Date”, }, startingTime: { type: “string”, label: “Starting Time”, }, }, async run({ steps, $ }) { // Parse the starting and ending dates const startDate = new Date(this.startingDate); const endDate = new Date(this.endingDate); // Set the starting time const [hours, minutes] = this.startingTime.split(“:”); startDate.setHours(hours, minutes); // Set the ending time to 23:59:59 endDate.setHours(23, 59, 59); // Format the dates in the required format const startDateTime = startDate.toISOString(); const endDateTime = endDate.toISOString(); // Create the Google Calendar event using the formatted dates const response = await axios($, { method: “POST”, url: “https://www.googleapis.com/calendar/v3/calendars/primary/events”, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, “Content-Type”: “application/json”, }, data: { summary: “Your event summary”, start: { dateTime: startDateTime, }, end: { dateTime: endDateTime, }, }, }); return response; }, });
Write me a script which will have a starting date filter that will take my STARTING DATE and TIME and format it to correctly to insert into Google Calendar.
To create a Google Calendar event with the correct starting date and time based on the user’s input, you can use the following code snippet in a Pipedream code step. This code assumes you have the starting date and starting time from a previous step or user input. ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google”, }, startingDate: { type: “string”, label: “Starting Date”, }, startingTime: { type: “string”, label: “Starting Time”, }, }, async run({ steps, $ }) { // Parse the starting date const startDate = new Date(this.startingDate); // Set the starting time const [hours, minutes] = this.startingTime.split(“:”); startDate.setHours(hours, minutes); // Format the date in the required format const startDateTime = startDate.toISOString(); // Create the Google Calendar event using the formatted date const response = await axios($, { method: “POST”, url: “https://www.googleapis.com/calendar/v3/calendars/primary/events”, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, “Content-Type”: “application/json”, }, data: { summary: “Your event summary”, start: { dateTime: startDateTime, }, end: { dateTime: startDateTime, // You can modify this to set the desired end time }, }, }); return response; }, });
Here’s a script that takes the starting date and starting time as input and returns the formatted date and time: export default defineComponent({ props: { startingDate: { type: "string", label: "Starting Date (yyyy-mm-dd)", }, startingTime: { type: "string", label: "Starting Time (hh:mm)", }, }, async run({ steps, $ }) { const startDate = new Date(this.startingDate); const [hours, minutes] = this.startingTime.split(":"); startDate.setHours(hours, minutes); const formattedDate = startDate.toISOString().replace(".000Z", "+01:00"); return formattedDate; }, }); This script will ask for the starting date and starting time, and then return the date and time in the format yyyy-mm-ddThh:mm:ss+01:00.