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
import { api, LightningElement } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class ToastComponent extends LightningElement {
@api title;
/* Title of the toast */
@api message;
/*
Message of the toast. If you wanted to display the Clickable url in the toast then the message format will be
'Record {0} created! See it {1}!'
public class OTPGenerator {
@InvocableMethod(description='This method will be generating the OTP for users to Login'
label='Generate OTP'
category='OTP')
public static List<String> generateOtp(){
List<String> responseList = new List<String>();
String randomIntegerString = string.valueof(Math.abs(Crypto.getRandomInteger()));
String otp = randomIntegerString.substring(0,6);
responseList.add(otp);
<apex:page standardController="Lead" recordSetVar="leadRecord" extensions="VE_AutoLeadController" lightningStylesheets="true" >
<apex:slds />
<!-- LEFT({!$Api.Partner_Server_URL_260}, FIND( '/services', {!$Api.Partner_Server_URL_260})) -->
<!-- LEFT( {!$Flow.FaultMessage}, Find("You can look up ExceptionCode", {!$Flow.FaultMessage} ) -1) -->
<apex:pageBlock title="Selected Records">
<apex:pageBlockTable value="{!selectedLeadRecords}" var="lead">
<apex:column headerValue="Name" value="{!lead.Name}" />
<apex:column headerValue="Email" value="{!lead.Email}" />
<apex:column headerValue="Company" value="{!lead.Company}" />
<apex:column headerValue="Rating" value="{!lead.Rating}" />
public class VE_AutoLeadController {
public List<String> leadIdsSet { get; set; }
public List<Lead> selectedLeadRecords { get; set; }
public VE_AutoLeadController(ApexPages.StandardSetController setController) {
selectedLeadRecords = (Lead[])setController.getSelected();
leadIdsSet = new List<String>();
for(sObject sobj : setController.getSelected()){
leadIdsSet.add( (String)sObj.get('Id') );
Public class AutoConvertLeads {
@InvocableMethod(label='Custom Lead Convert'
description='Apex Class converts the leads based in the Ids sent from flow'
category='Lead')
public static List<List<String>> LeadCovert(List<List<String>> leadIds){
// Query on the LeadStatus Object to find the correct converted status
LeadStatus convertedLeadStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
List<Database.LeadConvert> leadsToConvert = new List<Database.LeadConvert>();
List<String> leadIdsToConvert = leadIds.get(0);
// Loop with the Records Ids and prepare to Conver leads
<apex:page standardController="Lead" recordSetVar="leadRecord" extensions="VE_AutoLeadController" lightningStylesheets="true" >
<apex:slds />
<!-- LEFT({!$Api.Partner_Server_URL_260}, FIND( '/services', {!$Api.Partner_Server_URL_260})) -->
<!-- LEFT( {!$Flow.FaultMessage}, Find("You can look up ExceptionCode", {!$Flow.FaultMessage} ) -1) -->
<apex:pageBlock title="Selected Records">
<apex:pageBlockTable value="{!selectedLeadRecords}" var="lead">
<apex:column headerValue="Name" value="{!lead.Name}" />
<apex:column headerValue="Email" value="{!lead.Email}" />
<apex:column headerValue="Company" value="{!lead.Company}" />
<apex:column headerValue="Rating" value="{!lead.Rating}" />
@amitastreait
amitastreait / OpenCageGeocoderUtilErrorMock.java
Created February 12, 2022 08:01
Test class for OpenCage Geocoding API Forward Geocoding in Salesforce
@IsTest
public class OpenCageGeocoderUtilErrorMock implements HttpCalloutMock {
public static HttpResponse respond(HttpRequest httpReq){
String fakeResponse = '{}';
HttpResponse httpRes = new HttpResponse();
httpRes.setStatusCode(401);
httpRes.setHeader('Content-Type', 'application/json');
public class TransactionLogHandler {
public static void doHandleException(System.Exception ex , String processName){
//TransactionLogHandler.doHandleException();
Error_Log__c transactionLog = new Error_Log__c (
Log_Details__c = ex.getStackTraceString() +'<br/> <strong> Mesage is </strong> ' + ex.getMessage()
+ '<br/> ' + ex.getCause() +' <br/> '+ ex.getTypeName()+' <br/> '+ex.getLineNumber(),
Lod_DateTime__c = System.Now(),
Process_Name__c = processName
);
<!-- sldsValidatorIgnore -->
<!-- sldsValidatorIgnore -->
<!--
@description :
@author : Amit Singh
@group :
@last modified on : 12-21-2021
@last modified by : Amit Singh
-->
<template>
<design:component>
<design:attribute name="value" description="The value for RichText Area Component"/>
<design:attribute name="label" description="The Label for RichText Area Component"/>
<design:attribute name="required" description="Input is required or not value should be true or false"/>
<design:attribute name="placeholder" description="The place holder"/>
</design:component>