Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
539 views
in Technique[技术] by (71.8m points)

javascript - How to get Google calendar event attachment using Apps Script

I have written a Google Apps Script which successfully attaches a Google Sheets document to a newly created Calendar Event. The following code shows how this is achieved:

var eventObj = { 
    summary: eventName,
    start: {dateTime: startDate.toISOString()},
    end: {dateTime: endDate.toISOString()},
    attachments: [{
      'fileUrl': 'https://drive.google.com/open?id=' + fileID,
      'title' : 'Booking Sheet'
    }]
  };
  
  Calendar.Events.insert(eventObj, inStorePartiesCalendarID, {'supportsAttachments': true});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You want to retrieve file IDs from an event. If my understanding is correct, how about this sample script?

Sample script :

var inStorePartiesCalendarID = "### calendar ID ###";
var eventId = "### Event ID ###";
var res = Calendar.Events.get(inStorePartiesCalendarID, eventId, {fields: "attachments/fileId"});
var fileIds = res.attachments.map(function(e){return e.fileId});
Logger.log(fileIds)

Note :

  • This sample script supposes that you have already known the event ID. If you need the method for retrieving the event IDs. Please tell me.
  • If you want to retrieve the file ID and filename of the attachment file, please use attachments(fileId,title) for fields.

References :

If I misunderstand your question, I'm sorry.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...