Skip to content

Instantly share code, notes, and snippets.

View LokeshSagi's full-sized avatar

Lokesh Sagi LokeshSagi

View GitHub Profile
/* eslint-disable no-useless-escape */
/* eslint-disable radix */
/* eslint-disable consistent-return */
/* eslint-disable no-console */
import ID from '@salesforce/schema/SBQQ__Quote__c.Id';
import { fireEvent } from "c/pubsub";
import NAME_FIELD from '@salesforce/schema/Account.Name';
@LokeshSagi
LokeshSagi / autoFormatPhone.html
Created March 28, 2020 14:01
Auto format US phone numbers in (xxx) xxx-xxxx format
<template>
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-1 slds-large-size_6-of-12 slds-p-horizontal--small">
<div class="slds-form-element slds-p-top_medium">
<label class="slds-form-element__label">Phone number<abbr class="slds-required"
title="required">*</abbr></label>
<div class="slds-form-element__control">
<span onkeypress={keyCheck} onchange={keyCheck}>
<lightning-input-field data-req="required" data-address="phone" data-id="phone" field-name="Phone"
variant="label-hidden"></lightning-input-field>
.error input {
background-color: rgb(255, 255, 255);
border-color: rgb(194, 57, 52);
box-shadow: rgb(194, 57, 52) 0 0 0 1px inset;
background-clip: padding-box;
}
.error {
background-color: rgb(255, 255, 255);
border-color: rgb(194, 57, 52);
public class GoogleAPI {
//Generic method to get GoogleAPIKey from Custom Label.
public static String getAPIKey() {
String api = Label.GoogleAPIKey;
return api;
}
//Generic Http Callout Method
<template>
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-1 slds-medium-size_12-of-12 slds-large-size_12-of-12 slds-align_absolute-center">
<button class="slds-button slds-button_brand" onclick={handleCurrentLocation}>Get my current
location</button>
</div>
</div>
</template>
public class ServiceClass {
public void sampleMethod(String accountIdParent) {
// Define the Unit of Work instance.
// Mention the objects in independent to dependent order.
fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(new List<SObjectType> { Account.SObjectType,
Contact.SObjectType,
AccountContactRelation.SObjectType});
// Selector class
AccountContactRelationSelector acsSelector = new AccountContactRelationSelector();
public without sharing class AccountSelector extends fflib_SObjectSelector {
// super(false, false, false) - Constructor
// 1st param -> includeFieldSetFields (Set to true if the Selector queries are to include Fieldset fields as well)
// 2nd param -> enforceCRUD (To enforce object level permissions)
// 3rd param -> enforceFLS (To enforece Field Level Security)
public AccountSelector() {
super(false, false, false);
}
// Define all the fields required
public void saveDocuments() {
fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(new List<SObjectType> { SBQQ__Quote__c.SObjectType });
// pass your Domain class name to getTriggerEvent method of fflib_SObjectDomain.
// Call disableAll() to disable all trigger contexts.
// Call individual contexts if need to disable in that way -- disableBeforeInsert(), disableBeforeUpdate(), disableAfterUpdate() etc
fflib_SObjectDomain.getTriggerEvent(Quotes.class).disableAll();
// Do DML only if the trigger context is disabled.
<template>
<template if:true={label}>
<li data-index={index} style={hideSelectedPicklist} role="presentation"
onclick={handleSelectPicklist} class="slds-listbox__item" aria-disabled="true">
<div class="slds-media slds-listbox__option slds-listbox__option_entity slds-listbox__option_has-meta"
role="option">
<span class="slds-media__body">
<span class="slds-listbox__option-text slds-listbox__option-text_entity">{label}</span>
</span>
</div>
public class GooglePlacesAPI {
//Method to make a Callout to Google Place API to get search predications based on input search string
@AuraEnabled(cacheable=true)
public static String getAddressSet(String searchText, Boolean isPersonal){
String result = null;
system.debug('searchText is ' + searchText);
try{
if(searchText != null) {
String apiURL;
// String endpoint = 'callout:Google_Places_API'+EncodingUtil.urlEncode(searchText, 'UTF-8') + '&key=' + getAPIKey();