Skip to content

Instantly share code, notes, and snippets.

View amitastreait's full-sized avatar
🎯
Creativity ki potli liye chala ja raha ek bairagi

Amit Singh amitastreait

🎯
Creativity ki potli liye chala ja raha ek bairagi
View GitHub Profile
@amitastreait
amitastreait / UploadFile.js
Created April 7, 2021 08:12
Custom File Uploader using Lightning Web Component
import { LightningElement, api } from 'lwc';
import saveTheChunkFile from '@salesforce/apex/FileUploadService.saveTheChunkFile';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
const MAX_FILE_SIZE = 4500000;
const CHUNK_SIZE = 750000;
export default class UploadFile extends LightningElement {
@api recordId;
fileName = '';
@amitastreait
amitastreait / FileUploadService.java
Created April 7, 2021 08:10
Custom File Uploader using Lightning Web Component
public with sharing class FileUploadService {
@AuraEnabled
public static Id saveTheChunkFile(Id parentId, String fileName, String base64Data, String contentType, String fileId){
base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
if ( String.isBlank(fileId) ) {
fileId = saveFiles(parentId, fileName, base64Data );
} else {
appendToFile(fileId, base64Data);
@amitastreait
amitastreait / WhatsAppWebhook.java
Created August 29, 2023 16:53
WhatsAppWebhook
@RestResource(urlMapping='/whatsapp/webhooks/v1/*')
global without sharing class WhatsAppWebhook {
private static Final String SIGNATURE_VALID_MESSAGE = 'Signature Verified';
private static Final String SIGNATURE_NOT_VALID_MESSAGE = 'Signature could not be verified';
@HttpGet // GET
global static void doGet() {
RestResponse response = RestContext.response;
RestRequest request = RestContext.request;
.btnIconOverlay {
position: absolute;
z-index: 1;
margin: 0% 0px 0px 88%;
}
@amitastreait
amitastreait / SOQL Use case for practice
Created May 5, 2023 05:50
SOQL Use case for practice in salesforce.
1. What is SOQL in Salesforce?
2. What is the Structure of the SOQL Query in Salesforce?
3. List All the Contact Records
4. List All the Contact Records where the Email is not blank
5. List All the Contact Records Where the Email is Blank
6. List All the Contact Records Where the Title contains the developer
7. List All the Contact Records Where the Title Starts with the Manager
8. List All the Opportunity Where the Amount is more than 29000
9. List All the Opportunity count state wise
10. List All the Opportunity Amount Stage Wise
@amitastreait
amitastreait / Get Refresh Token using the Postman Pre-Request Script.js
Last active March 5, 2024 11:04
Get Refresh Token using the Postman Pre-Request Script
if(pm.response.code === 200 || pm.response.code === 201){
var responseBody = pm.response.json();
pm.environment.set('access_token', responseBody.access_token);
pm.environment.set('refresh_token', responseBody.refresh_token);
pm.environment.set('scope', responseBody.scope);
pm.environment.set('id_token', responseBody.id_token);
pm.environment.set('instance_url', responseBody.instance_url);
pm.environment.set('token_type', responseBody.token_type);
import { LightningElement, track, wire } from 'lwc';
import listAllMessages from '@salesforce/apex/WhatsAppLWCService.listAllMessages';
import sendTextMessage from '@salesforce/apex/WhatsAppLWCService.sendTextMessage'
import getSingleMessage from '@salesforce/apex/WhatsAppLWCService.getSingleMessage';
import { subscribe, unsubscribe, onError } from 'lightning/empApi';
export default class Chatcomponent extends LightningElement {
@track messages;
<template>
<lightning-card variant="Narrow" >
<lightning-button if:true={messageList} variant="border-filled"
label="Chat with another customer" onclick={handleAnOtherChat} slot="actions">
</lightning-button>
<lightning-spinner alternative-text="Loading" size="small" if:true={isSpinner}></lightning-spinner>
<div class="slds-p-horizontal_small">
@amitastreait
amitastreait / ContentManager.js
Last active January 16, 2024 06:23
How to preview files in Lightning Community using LWC
import { api, LightningElement, track, wire } from 'lwc';
import getContentDetails from '@salesforce/apex/ContentManagerService.getContentDetails';
import deleteContentDocument from '@salesforce/apex/ContentManagerService.deleteContentDocument';
import getLoginURL from '@salesforce/apex/ContentManagerService.getLoginURL';
import { NavigationMixin } from 'lightning/navigation';
const columns = [
{ label: 'Title', fieldName: 'Title', wrapText : true,
cellAttributes: {
iconName: { fieldName: 'icon' }, iconPosition: 'left'
@amitastreait
amitastreait / OrderLineItem.java
Created April 6, 2021 06:43
How to Create order Line Item in salesforce Apex
Product2 p = new Product2();
p.Name = 'Test Product';
p.Description='Test Product';
p.productCode = 'ABC';
p.isActive = true;
insert p;
PricebookEntry standardPrice = new PricebookEntry();
standardPrice.Pricebook2Id = Test.getStandardPricebookId();
standardPrice.Product2Id = p.Id;