How to implement Full Calendar Js in Lightning Web Component?

Hey #Trailblazers,

In this blog post we will discuss how we can implement the Lightning Calendar in Lightning Web Component using Full Calendar V3 Library.

Full Calendar library has many features that we can use to display the event information. To read more about this Visit https://fullcalendar.io/

Features

  1. Show the Events in Monthly, Daily, and Weekly view
  2. Show the Event Details when clicked on Event Title
  3. Show the Created Record wizard when user clicks on any day area

Now, let’s say that a business wants to display the information about the events inside a particular record page, home page or app page and that has the ability to display the event information in a modal and can drag & drop the event.

Complete Code

Here is the Link which has to update the code.

GitHub Repo

So let’s start implementation.

Download the V3 Full calendar Js from https://fullcalendar.io/ and upload as static resource in Salesforce Environment.

Create a Lightning Web Component and use below code

Now, Create Apex Class and use below code. Apex Class is used to get the Event from the Salesforce Event object

You can find the full code here including static resource

https://github.com/amitastreait/full-calendar-js

Add your component inside any record page, home page or app page and see the demo

 

Output when clicked on event title

 

 

Output when clicked on any day

 

 

Thanks for reading 🙂

Sharing is caring 🙂 If you have any query please feel free to put down into the comment section.

#Salesforce #SFDCPanther #DeveloperGeeks

Amit Singh
Amit Singh

Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion

Articles: 299

Newsletter Updates

Enter your email address below and subscribe to our newsletter

85 Comments

  1. Love you brother!! After almost two weeks I landed onto this blog and finally I am able to load/see calendar. Thank you so much brother! 🙂

      • Hello, I hope you still follow the thread. Where do I put the code from the codepen to make my calendar like this one on the link ?

        Thank you

        • Yes. I am following. However, I am not getting time these days so I am not able to help you where to put the code. You can check how the calendar is being prepared then make the changes accordingly

  2. I have implemented your blog and now I want to change that to resource timeline. Can you please tell me where I have to make changes and what changes should I make. Thanks

  3. Hi,
    I have downloaded and uploaded fullcalender 3.10.0 version ,uploaded in static resource and added the LWC and Apex class codes above, but resources are not accessible in the LWC, not sure why. could please let me know what could be the reason
    Failed to load resource: the server responded with a status of 404 (Not Found) -/resource/1602750041000/FullCalendarJS/jquery.min.js
    /resource/1602750041000/FullCalendarJS/moment.min.js
    /resource/1602750041000/FullCalendarJS/fullcalendar.min.css

  4. Thanks a lot buddy. This helped me a lot. I have previously implemented the Calender using Aura Component. If anyone wants that I can share the code.

    In Lwc one problem still I am facing is ex: in event click you are assigning the event to LWC @track variable selectedEvent. But that is not getting assigned.

    My requirement: I need to call LWC js methods on event click and eventResize. but when we use this.somelwcmethod, this will not work since this is being assumed as Calendar`s related.

    So I have created another module in js and made it to work. But I want to know how that conflict of this can be resolved.

  5. Hi Amit,
    Getting below error:
    FullCalendarJS/fullcalendar.min.css net::ERR_ABORTED 404 (Not Found)
    FullCalendarJS/theme.js 404 (Not Found)
    /FullCalendarJS/moment.min.js 404 (Not Found)
    /jquery.min.js 404 (Not Found)
    FullCalendarJS/fullcalendar.min.js 404 (Not Found)

  6. Hi,

    This works great! But, how can I put in a different theme for the calendar that is more updated looking.

    Thanks!

  7. I am still getting Errors… I put everything repo you provided into static resources
    Getting below error:
    FullCalendarJS/fullcalendar.min.css net::ERR_ABORTED 404 (Not Found)
    FullCalendarJS/theme.js 404 (Not Found)
    /FullCalendarJS/moment.min.js 404 (Not Found)
    /jquery.min.js 404 (Not Found)
    FullCalendarJS/fullcalendar.min.js 404 (Not Found)

  8. Hi, My calendar is working but I am very stuck. I want to use NavigationMixin on the eventclick to navigate to record page. I can make this work outside the calendar, but inside it always comes up as function undefined. How can I call a function within eventclick that uses NaviagtionMixin? Thanks for your help! This one is killing me…. I cannot seem to reference any function as “this” does not seem to reference my class.

  9. Hi Amit,

    I have done as you mentioned but it is not working. The root files are missing from the Zip folder and i am getting the following errors. I would be grateful if you can share those files to my email id.

    fullCalendarJs.js:4 Object
    eval @ fullCalendarJs.js:4
    /resource/1608632982000/FullCalendarJS/jquery.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    /resource/1608632982000/FullCalendarJS/theme.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    /resource/1608632982000/FullCalendarJS/moment.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    /resource/1608632982000/FullCalendarJS/fullcalendar.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    fullcalendar.min.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)

    Thank you Gaurav!

  10. A note for everyone here, just failed security review due to the jquery version that Calendar 3.10 uses. Hope I can save you some time, you need to go to a higher version, and that plays nowhere near as nice with LWC.

  11. Just a heads up, if you are building this for app exchange you will probably need v4 or v5. I have been using this for a number of years and my latest package was bounced from security review due to vulnerabilities in v3 and the jquery version it uses. Would love to see this updated to v4 or if you are up for a serious challenge v5. I have been banging my head against that all morning and it looks like a lot of people are struggling with it.

  12. Got this all setup on my org without an issue. Just one thing that I cannot get working is the event click to show the modal pop up. I have the this.selectedEvent = event but the modal never shows. I printed out the track values but those never seem to change either. Have you seen any issues with this or any idea on how to solve this? Thats my only roadblock so far. Thanks!

  13. Hi Amit

    It’s working fine for me but I wnat to display Holidays in different color.

    is there any way to display holiday in different colors?

    Thanks In Advanced!

  14. Hi
    am getting an error like this
    ‘Invalid reference FullCalendarJS of type resourceUrl in file fullCalendarJs.js’

      • No i have already uploaded the static Resource with the name as FullCalendarJS and still getting the same error.

        • You can check below comments by a blog reader

          Hi Amit,

          I was facing same issue, resource 404 not found, ended up uploading all files individually.
          But would like to know why facing problem with the zip file. tried with namespace as well but no luck.

          Steps I took:
          -Created all 6 files in local from your drive, copy pasted
          -Moved all files in a new folder, renamed and zipped it
          -Uploaded in static resource, rechecked the label and use it in LWC js file.

          Thanks for awesome work

  15. Hello Amit Sir ,
    Can you please guide us how to use moment timezone plugin in the lwc since we wanted to show according to the timezone as per the logged in user and if I am using the below link reference it is showing us the below error
    TypeError: t.createPlugin is not a function
    from the following main.global.min.js

    The link which I am using as a reference for Moment time zone is below
    https://fullcalendar.io/docs/moment-timezone-plugin

  16. Hi, I followed all the steps, unfortunatly my LWC is only showung All Calender word. Except that no calender is showing, may I know how can I fix that?

  17. Hi

    I tried everything but the “fullcalendar” css sends an error and wont display the calendar.
    I have read the comments and tried multiple options and haven’t had any luck, any suggestions?

  18. Hi Amith,

    Thanks for the blog and it so informative

    I have a requirement need to create a custom component to create Event calendar for Accounts
    On Calendar- Other Calendar settings – ability to create an event calendar for an Account or other objects(instead People).

    Component to include:
    List of today and future events related to an account
    User filter required to select single or multiple accounts
    How to achieve this?

    Many Thanks,
    Latha

    • Hi Laths,

      This is the customize requirement that you are talking about. You need to create a multi select lookup component which will search for accounts and then upon clicking on find events then you need to call the Apex Class Method which will accept List and then filter the events based on WhatId.

  19. Hi everyone,

    The current repository is working fine for me but when I try to load the latest library files, I am getting an error in console. The calendar does not load as well. Could someone please help me?

    Versions I am trying to use:
    fullcalendar.min.js – v5.10.1
    fullcalendar.min.css – v5.10.1
    jquery.min.js – v3.6
    moment.min.js – v2.27
    theme.js – v4.4.2

    The following error is captured in the “catch” of Promise() to load the scripts
    {message: ‘Error occured on FullCalendarJS’, error: undefined}
    error: undefined
    message: “Error occured on FullCalendarJS”

  20. Hi everyone,

    I am trying to add the LWC generated from this to a Vlocity OmniScript and receiving the following error. Could anyone please let me know if they tried/imported an LWC using fullcalendar.js into a Vlocity component?

    “Assertion Failed!: Scoped imports not allowed when a runtime namespace is specified”

    Thanks,

  21. Thanks for sharing your component. I am looking to change the “day” to “Day”, “month” to “Month” etc. Can you please help me where do I need to change it?

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from Panther Schools

Subscribe now to keep reading and get access to the full archive.

Continue reading