Skip to content

Instantly share code, notes, and snippets.

View choudharymanish8585's full-sized avatar
💭
Never Settle

Manish Choudhari choudharymanish8585

💭
Never Settle
View GitHub Profile
({
doInit : function(component) {
var visualforceDomain = "https://" + component.get("v.visualforceDomain");
/**
* Adding a new event listner on window object
* to listen for message event
**/
window.addEventListener("message", function(event) {
//Check if origin is not your org's my domain url, in this case, simply return out of function
if (visualforceDomain.indexOf(event.origin) == -1) {
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="message" type="String"/>
<aura:attribute name="visualforceDomain" type="String"
default="manish-winter19-dev-ed--c.visualforce.com"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:card title="Post Message Demo">
<lightning:layout multipleRows="true">
<lightning:layoutItem padding="around-large">
/**
* Initializing fullcalendar with appropriate option and handlers
* using Singleton Pattern
* */
const CalendarSingleton = (function(){
let calendarInstance;
function createCalendar(){
//Initialize Full Calender
//and render inside 'calendar' div
global class FullCalendarDemo{
@RemoteAction
global static List<User_Calendar__c> getEvents() {
String userId = UserInfo.getUserId() ;
List<User_Calendar__c> userCalendar = [SELECT Id, Name, User__r.Name,
Event__c, Event__r.Name, Event__r.Start_Time__c, Event__r.End_Time__c
FROM User_Calendar__c
WHERE User__c=:userId];
if(userCalendar.size()>0){
<apex:page lightningStylesheets="true" controller="FullCalendarDemo">
<apex:stylesheet value="{!URLFOR($Resource.fullcalendar,'fullcalendar/fullcalendar.min.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.fullcalendar,'fullcalendar/jquery-ui.min.css')}"/>
<apex:includeScript value="{!URLFOR($Resource.fullcalendar,'/fullcalendar/jquery.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.fullcalendar,'/fullcalendar/jquery-ui.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.fullcalendar,'/fullcalendar/moment.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.fullcalendar,'/fullcalendar/fullcalendar.min.js')}"/>
<apex:includeScript value="{!$Resource.FullCalendarDemo}"/>
<html>
<head>
/**
* Class to demo new Url.getOrgDomainUrl() and UserInfo.getSessionId() methods
*/
public class SameOrgApiDemo{
//This method will make a call to same org
public static void getOrgLimits(){
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(Url.getOrgDomainUrl().toExternalForm()
/**
* This class will run in with sharing context if
* -It is visualforce page controller
* -It is entrypoint in the transaction (like api)
* This class will run in without sharing context if
* -It is being called from another class having without shring permission
**/
public inherited sharing class InheritedSharing{
public List<Contact> getAllTheSecrets(){
{
"data":{
"event":{
"createdDate":"2018-08-22T09:06:51.980Z",
"replayId":7,
"type":"updated"
},
"sobject":{
"Type":null,
"Phone":null,
({
handleMessage : function(component, event, helper) {
const param = event.getParam('message');
console.log(`Account "${param.sobject.Name}" with Id ${param.sobject.Id} is ${param.event.type}!!`);
}
})
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
<!--Include StreamingApiHandler child component and pass channel name to subscribe
ex: "/topic/AccountSpy" is my pushtopic channel name
once the event is fired, it will handled in handleMessage controller method -->
<c:StreamingAPIHandler channelName="/topic/AccountSpy" onStreamEvent="{!c.handleMessage}" />
<lightning:card footer="Please check browser console for latest captured event"
title="Account Spy"
iconName="standard:search">
<p class="slds-p-horizontal_small">