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 / 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);
<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 / ContentVersionTrigger.java
Created October 13, 2023 05:55
ContentVersionTrigger.java
trigger ContentVersionTrigger on ContentVersion (after insert) {
/*
* Develop a solution so that whenever a file is getting inserted under Task,
* Event or Case Object the same file should be linked to the related Account Record
*/
Set<Id> contentDocumentIdsSet = new Set<Id>();
/* Step1 - Get the content document Id */
for(ContentVersion version: Trigger.New){
contentDocumentIdsSet.add(version.ContentDocumentId);
}
@amitastreait
amitastreait / GoogleDriveWebService.java
Created October 9, 2023 15:01
Upload file to Google Drive
public static void UploadFile(String fileName, String bodyEncoded, String contentType) {
String fileExtension = fileName.substring(fileName.indexOf('.')+1, fileName.length());
String boundary = '----WebKitFormBoundary7MA4YWxkTrZu0gW';
String header = '\r\n--' + boundary + '\r\n';
String footer = '\r\n--' + boundary + '--';
String fileNameToUpload = fileName;//+'.'+fileExtension.trim();
String folderId = '19xl6WOmqZIfLCukX4YskGqlQIRSZDzXc';
List<String> listofFolderId = new List<String>();
listofFolderId.add(folderId.trim());
String body = header + 'Content-Type: application/json\r\n\r\n'
@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;
public class DateClassUtility {
@InvocableMethod(label='Date Operations'
description='Operations related to date class'
category='Date Utils'
iconName='slds:standard:date_time'
)
// iconName - <slds:category:name> // see
// iconName - <resource:namespace:resourceId> // managed packages
public static List<Date> dateUtils(List<InputWrapper> inputs){
IF(
TEXT( Department__c )="IT",
IMAGE("https://www.vecteezy.com/vector-art/5928014-it-logo-design-for-information-technology-company-logo-design-vector", "Information Technology", 200, 200) ,
IF(
TEXT( Department__c )="CSE",
.btnIconOverlay {
position: absolute;
z-index: 1;
margin: 0% 0px 0px 88%;
}
@amitastreait
amitastreait / WhatsAppUtils.java
Created May 18, 2023 07:25
Send template message using WhatsApp
public class WhatsAppUtils {
public static List<WAMessage__c> listAllMessageByCustomer(String customerPhone){
List<WAMessage__c> messages = new List<WAMessage__c>();
messages = [SELECT Id, Name, MessageContent__c, MessageType__c, Outgoing__c FROM WAMessage__c WHERE CustomerPhone__c =: customerPhone];
return messages;
}
public static WAMessage__c sendTextMessage(String messageContent, String toPhone){
HttpRequest httpReq = new HttpRequest();
@amitastreait
amitastreait / ChatGPTClass.java
Created May 13, 2023 08:55
How to integrate CHAT GPT with Salesforce
global without sharing class ChatGPTClass {
// ChatGPTClass.generateResponse('Hello');
@AuraEnabled
public static String generateResponseFromGPT(String queryText){
try {
String content = generateResponse(queryText);
return content;
} catch (Exception e) {