function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
aebenaeben 

Accessing public calendars and resources in APEX

Is there a way to access public calendar and resources from APEX? 

 

Here is what I trying to do:

 

Given a event, I want to find the name of the public calendar and also find the name of the resource invited to the event. Event.OwnerId gives me the public calendar id. But, I not able to find the public calendar name. Likewise, I can query EventAttendee to find the AttendeeId, but I can't seem to find a way find to find the resource name.

 

Any thoughts / suggestions? Thanks a lot.

MJ09MJ09

Odd, but true: There's no way to determine the Id of a Public Calendar. There's no SObject you can query to get it.

 

I usually create a list-type Custom Setting for this. Whenever I create a Public Calendar, I manually add its name and Id to the custom setting. Then my Apex code can query the Custom Setting to get the Id when I need it.

 

If you do this, don't forget the Custom Setting when you deploy -- you'll have to create the Public Calendars in Production, deploy the Custom Setting, and populate it with the Names and Ids before you deploy the rest of your work.

 

Kiran Kumar GottulaKiran Kumar Gottula
@aeben I am creating an Event using Flow. So i want to insert this Event to Public Calendar. How can add this Event to Public Calendar. Where can i map this.
 
phuongtran2015phuongtran2015
You can access it finally in current api version 45, "SELECT Id,Name FROM Calendar where Type='Resource'
David Roberts 4David Roberts 4
Type = 'Public'
SELECT Id FROM Calendar WHERE Type = 'Public' AND Name = '<Public Calendar Name>'