Skip to content

Instantly share code, notes, and snippets.

View suddeb's full-sized avatar

Sudipta Deb suddeb

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
public with sharing class TaskTriggerHandler {
public void handleTaskCreation(){
List<Task> allTasks = [ SELECT
TYPEOF What
WHEN Case THEN Id, CaseNumber
WHEN Account THEN Id, Name
END
FROM TASK Where Id in: Trigger.new
];
for(Task singleTask : allTasks){
@suddeb
suddeb / SwitchFunction
Created July 25, 2018 16:02
SwitchFunction
public with sharing class SwitchFunction {
public static void switchOnString(String value){
switch on value {
when 'India' {
System.Debug('I am in India');
}when 'Canada' {
System.Debug('I am in Canada');
}when else {
<apex:page showHeader="false" sidebar="false" controller="ContinuationExperimentController">
<apex:form>
<apex:pageBlock title="Experiment with Continuation - Calling Service Async">
<apex:commandButton action="{!callService}" value="Call Service" reRender="response" />
</apex:pageBlock>
<apex:pageBlock title="Response received from Service" id="response">
<pre>{!res}</pre>
</apex:pageBlock>
/*
* Author : Sudipta Deb
* Blog : www.sudipta-deb.in
*/
public with sharing class ContinuationExperimentController {
public String res {get;set;}
public String resLongRunServ {get;set;}
public String continuationId;
public String continuationIdLongRunSrv;
<apex:page showHeader="false" sidebar="false" controller="ContinuationExperimentController">
<apex:form>
<apex:pageBlock title="Experiment with Continuation Object - Calling Service Async">
<apex:commandButton action="{!callService}" value="Call Service" reRender="response" />
</apex:pageBlock>
<apex:pageBlock title="Response received from Service" id="response">
<pre>{!res}</pre>
</apex:pageBlock>
@suddeb
suddeb / DynamicSOSLPractice
Created October 3, 2016 01:55
DynamicSOSLPractice
public with sharing class DynamicSOSLPractice {
/*
This method will prepare SOSL statement to search for the keyword in all the fields for the objects
Account, Lead, Contact, sudipta__Book__c
*/
public static void testDynamicSOSL(){
String soslString = '';
String searchKeyword = 'Salesforce';
List<String> requiredsObjects = new List<String>{'Account', 'Lead', 'Contact','sudipta__Book__c'};
@suddeb
suddeb / DynamicSOSLStatement
Created October 3, 2016 00:32
DynamicSOSLStatement
List<List <sObject>> mySOSLQuery = search.query(<<DYNAMIC_SOSL_QUERY_STRING>>);
@suddeb
suddeb / CorrectDynamicSOQL
Created October 3, 2016 00:23
CorrectDynamicSOQL
MyCustomObject__c newCustomObject = new MyCustomObject__c(myCustomField__c ='My Custome Field');
String fieldValue = newCustomObject.myCustomField__c;
List<sObject> sObjList = Database.query('SELECT Id FROM MyCustomObject__c WHERE myCustomField__c = :fieldValue');
@suddeb
suddeb / MyCustomObject
Created October 3, 2016 00:22
MyCustomObject
MyCustomObject__c newCustomObject = new MyCustomObject__c(myCustomField__c ='My Custome Field');
List<sObject> sObjList = Database.query('SELECT Id FROM MyCustomObject__c WHERE myCustomField__c = :newCustomObject.myCustomField__c');