Skip to content

Instantly share code, notes, and snippets.

View durveshshah's full-sized avatar

Durrvesh Sshah durveshshah

View GitHub Profile
public class OpportunityTriggerHandler {
// Method to create the Account-Opportunity Map
public static Map<Id, List<Opportunity>> createAccountOpportunityMap(Set<Id> accountIds) {
// Step 1: Query Opportunities with related Account Ids
List<Opportunity> oppList = [
SELECT Id, AccountId, Name
FROM Opportunity
WHERE AccountId IN :accountIds
];
{
"thisAccount": {
"Name": "New Account",
"Phone": "1234567890"
},
"attachments": [
{
"Body": "Base64EncodedString",
"ContentType": "application/pdf",
"Name": "document.pdf"
global class MyBatch implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext context) {
// Return query locator for data retrieval
}
global void execute(Database.BatchableContext context, List<sObject> scope) {
// Process batch of records
}
global void finish(Database.BatchableContext context) {
@future
public static void myFutureMethod() {
// Perform asynchronous task here
}
public class MyQueueable implements Queueable {
public void execute(QueueableContext context) {
// Perform long-running task here
}
}
// Enqueue the Queueable job
System.enqueueJob(new MyQueueable());
trigger LeadChangeEventTrigger on LeadChangeEvent (after insert) {
LeadChangeEventHandler.publishLeadEvent(Trigger.new);
}
public class LeadChangeEventHandler {
public static void publishLeadEvent(List<LeadChangeEvent> leadEvents){
// List to hold the Lead_Created_Event__e records to be published
List<Lead_Created_Event__e> leadEventsToAdd = new List<Lead_Created_Event__e>();
Map<String, Object> changedFieldsWithValues = new Map<String, Object>();
// Gather IDs of deleted leads
Set<Id> deletedLeadIds = new Set<Id>();
for(LeadChangeEvent leadChangeEvent : leadEvents) {
EventBus.ChangeEventHeader header = leadChangeEvent.ChangeEventHeader;
import numpy as np
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
# Suppose we have data for smartphone options with features like price, screen size, and camera quality
# Let's generate some sample data for demonstration purposes
# Features: [price, screen size, camera quality]
X = np.array([
[500, 5.5, 12],
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
<target>lightning__RecordPage</target>
<target>lightning__Tab</target>
</targets>
public with sharing class getOpportunities {
@AuraEnabled
public static List<OpportunityWrapper> getAllOpportunities() {
List<OpportunityWrapper> opportunityWrapperList = new List<OpportunityWrapper>();
List<Opportunity> opportunityList = [SELECT Id,StageName,Name,Owner.Name, AccountId FROM Opportunity LIMIT 5];
for (Opportunity thisOpp : opportunityList) {
OpportunityWrapper wrapper = new OpportunityWrapper();
wrapper.accountId = thisOpp.AccountId;