• George Galaios 12
  • NEWBIE
  • 0 Points
  • Member since 2020
  • Salesforce Consultant / Developer
  • Cognity S.A.

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 2
    Replies
In my org users can change their locale and use Greek or English Language. So what i want to do is to get the Record Types of Lead and also to show their name field in the respective language (English or greek depending on the user's locale). I have tried to get the Record Types of the Lead Object and store them in a record choice set. I am doing it, but the name field is always in English.

User-added imageThen, i tried to use the RecordTypeLocalization object, but my problem is that i cannot ensure somehow that i will take the Lead's Record Types. It will actually get all the record types for all objects, since i, unfortunately, do not have the ability on my fiters to set Parent.Sobject = 'Lead'.
User-added image

Any suggestions on how i could solve my issue?
I am new to Javascript and LWC so this question might be very easy! But i can't find a way to implement it... For the time being, i have a listener that when a value of a variable changes, it handles the change. Now, i want to take it one step further... I want to put 2 more properties to this variable and have it to the listener. Is this possible ?? A code snippet until now:
 
/*
@ggalaios 07/04/2020 
*/

import { LightningElement, wire, track, api } from "lwc";
import { loadScript, loadStyle } from "lightning/platformResourceLoader"; //In order for fullCalendar to be displayed
import FullCalendarJS from "@salesforce/resourceUrl/FullCalendarJS"; //import the static Resource!
import { NavigationMixin } from "lightning/navigation"; //Import this in order to be able to pop-up the New Event Screen
import { encodeDefaultFieldValues } from "lightning/pageReferenceUtils";
import getMyEvents from "@salesforce/apex/fullCalendarController.getEventsForCurrentUser"; //in order to call fullCalendarController Apex Class
import { RecordFieldDataType } from "lightning/uiRecordApi";

export default class FullCalendarJs extends NavigationMixin(LightningElement) {
  @wire(getMyEvents) myEvents; //@wire is used to call automatically the Apex method!
  @track eventsList = [];
  currentEvent;
  @track eventView = {
    value: "timeGridWeek"
  };

  connectedCallback() {
    var targetProxy = new Proxy(this.eventView, {
      set: (target, key, value) => {
        alert(`${key} set to ${value}`);
        target[key] = value;
        const viewChangeEvent = new CustomEvent("viewchange", {
          detail: { data: target[key] }
        });
        // Fire the custom event
        this.dispatchEvent(viewChangeEvent);
        return true;
      }
    });
    this.eventView = targetProxy;
  }
}


Now i want to make it somehow like this:
 
@track eventView = {
    value: "timeGridWeek",
    startDate: "08/04/2020",
    endDate: "15/04/2020"
  };

How could i implement my listener since it has just three inputs? (Target, key, value.) Is it possible to add more arguments? Also, how could i modify my listener method? Thanks!
I have implemented fullCalendar.io to my Salesforce dev org in order to have a custom calendar lightning component. So I found an LWC that uses those libraries and made some minor changes. The reason why i went to this solution is because i could not get the event in default Salesforce Calendar when user changes view(for example Week to Day, Day to Month etc...). Now that i can see the custom Calendar into my Salesforce org, i need to find where i could get those events and make some changes. For example, i need to get the event when user changes from Week to Day, and change the events that are displaying in another component by firing an event and calling the respective Apex method. Any ideas how i could do this ??? Any help would be really appreciated :)

I post my code below:
HTML
<template>
  <div class="slds-card">
    <lightning-button
      label="New Event"
      title="New Event"
      onclick={createNewEvent}
    ></lightning-button>
    <div class="fullcalendar" lwc:dom="manual"></div>
  </div>
</template>

Javascript
import { LightningElement, wire, track, api } from "lwc";
import { loadScript, loadStyle } from "lightning/platformResourceLoader";
import FullCalendarJS from "@salesforce/resourceUrl/FullCalendarJS";
import { NavigationMixin } from "lightning/navigation";
import { encodeDefaultFieldValues } from "lightning/pageReferenceUtils";
import getMyEvents from "@salesforce/apex/fullCalendarController.getEventsForCurrentUser";
import { RecordFieldDataType } from "lightning/uiRecordApi";

export default class FullCalendarJs extends NavigationMixin(LightningElement) {
  @wire(getMyEvents) myEvents;
  @track eventsList = [];
  currentEvent;
  createNewEvent() {
    console.log("createNewEvent called");
    this[NavigationMixin.Navigate]({
      type: "standard__objectPage",
      attributes: {
        objectApiName: "Event",
        actionName: "new"
      },
      state: {
        nooverride: "1"
      }
    });
  }
  renderedCallback() {
    Promise.all([
      // First step: load FullCalendar core
      loadStyle(this, FullCalendarJS + "/packages/core/main.css"),
      loadScript(this, FullCalendarJS + "/packages/core/main.js")
    ])
      .then(() => {
        // Second step: Load the plugins in a new promise
        Promise.all([
          loadStyle(this, FullCalendarJS + "/packages/daygrid/main.css"),
          loadScript(this, FullCalendarJS + "/packages/daygrid/main.js"),
          loadStyle(this, FullCalendarJS + "/packages/timegrid/main.css"),
          loadScript(this, FullCalendarJS + "/packages/timegrid/main.js"),
          loadScript(this, FullCalendarJS + "/packages/interaction/main.js")
        ]).then(() => {
          // Third step: calls your calendar builder once the plugins have been also loaded
          this.initialiseFullCalendar();
          console.log("initialize!");
        });
      })
      .catch((error) => {
        // Catch any error while loading the scripts here
      });
  }

  initialiseFullCalendar() {
    //@ggalaios 03-04-2020 If events not null or undefined...
    if (this.myEvents) {
      let newEventList = [];
      this.myEvents.data.forEach((ele) => {
        newEventList.push({
          id: ele.Id,
          start: ele.StartDateTime,
          end: ele.EndDateTime,
          title: ele.Subject
        });
      });
      this.eventsList = newEventList;
    }
    const ele = this.template.querySelector("div.fullcalendar");
    console.log("ele >>> " + ele);
    var calendar = new FullCalendar.Calendar(ele, {
      //06/04/2020 @ggalaios: Custom button for New Event Creation
      customButtons: {
        myCustomButton: {
          text: "custom!",
          click: function () {
            console.log("called");
            this[NavigationMixin.Navigate]({
              type: "standard__objectPage",
              attributes: {
                objectApiName: "Event",
                actionName: "new"
              },
              state: {
                nooverride: "1"
              }
            });
          }
        }
      },
      header: {
        left: "prev,next,today",
        center: "title",
        right: "dayGridMonth,timeGridWeek,timeGridDay,myCustomButton"
      },
      plugins: [
        "interaction",
        "resourceDayGrid",
        "resourceTimeGrid",
        "dayGrid",
        "timeGrid",
        "timeline",
        "interactionPlugin"
      ],
      eventClick: function (info) {
        console.log("clicked the event");
        var eventObj = info.event;

        if (eventObj.url) {
          alert(
            "Clicked " +
              eventObj.title +
              ".\n" +
              "Will open " +
              eventObj.url +
              " in a new tab"
          );

          window.open(eventObj.url);

          info.jsEvent.preventDefault(); // prevents browser from following link in current tab.
        } else {
          alert("Clicked " + eventObj.title);
        }
      },
      events: this.eventsList,
      defaultView: "timeGridWeek"
    });

    calendar.render();
    //console.log(this.eventsList.data);
    console.log("Rendering");
  }
}

and a picture of the events i want to "catch"
Events
 
I am new to Javascript and LWC so this question might be very easy! But i can't find a way to implement it... For the time being, i have a listener that when a value of a variable changes, it handles the change. Now, i want to take it one step further... I want to put 2 more properties to this variable and have it to the listener. Is this possible ?? A code snippet until now:
 
/*
@ggalaios 07/04/2020 
*/

import { LightningElement, wire, track, api } from "lwc";
import { loadScript, loadStyle } from "lightning/platformResourceLoader"; //In order for fullCalendar to be displayed
import FullCalendarJS from "@salesforce/resourceUrl/FullCalendarJS"; //import the static Resource!
import { NavigationMixin } from "lightning/navigation"; //Import this in order to be able to pop-up the New Event Screen
import { encodeDefaultFieldValues } from "lightning/pageReferenceUtils";
import getMyEvents from "@salesforce/apex/fullCalendarController.getEventsForCurrentUser"; //in order to call fullCalendarController Apex Class
import { RecordFieldDataType } from "lightning/uiRecordApi";

export default class FullCalendarJs extends NavigationMixin(LightningElement) {
  @wire(getMyEvents) myEvents; //@wire is used to call automatically the Apex method!
  @track eventsList = [];
  currentEvent;
  @track eventView = {
    value: "timeGridWeek"
  };

  connectedCallback() {
    var targetProxy = new Proxy(this.eventView, {
      set: (target, key, value) => {
        alert(`${key} set to ${value}`);
        target[key] = value;
        const viewChangeEvent = new CustomEvent("viewchange", {
          detail: { data: target[key] }
        });
        // Fire the custom event
        this.dispatchEvent(viewChangeEvent);
        return true;
      }
    });
    this.eventView = targetProxy;
  }
}


Now i want to make it somehow like this:
 
@track eventView = {
    value: "timeGridWeek",
    startDate: "08/04/2020",
    endDate: "15/04/2020"
  };

How could i implement my listener since it has just three inputs? (Target, key, value.) Is it possible to add more arguments? Also, how could i modify my listener method? Thanks!
Hi all,

I am making use of fullcalendar js, I want to get the view name like 'month' when switching from week to month or 'agendaDay' when switching from week to day. Is there any method which fullcalendar is providing or any other way to get the value?

Thanks in advance
Hi all,

I am making use of fullcalendar js, I want to get the view name like 'month' when switching from week to month or 'agendaDay' when switching from week to day. Is there any method which fullcalendar is providing or any other way to get the value?

Thanks in advance