- 77
- 23 815
Sreedhar - Salesforce - INDIA
India
เข้าร่วมเมื่อ 8 ม.ค. 2017
UC - 12 Salesforce Apex Trigger by SREEDHAR
For more information reach me on
Email - sreedharcloud@gmail.com
WhatsApp - +917416795462
Email - sreedharcloud@gmail.com
WhatsApp - +917416795462
มุมมอง: 71
วีดีโอ
Part-3 UCs :SOQL - Salesforce Object Query Language by SREEDHAR
มุมมอง 87วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC -11 Salesforce Apex Trigger by SREEDHAR
มุมมอง 34วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-3 Salesforce Batch Apex by SREEDHAR
มุมมอง 26วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-2 Salesforce Batch Apex by SREEDHAR
มุมมอง 21วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-1 Salesforce Batch Apex by SREEDHAR
มุมมอง 99วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
PART - 2 :SOQL - Salesforce Object Query Language by SREEDHAR
มุมมอง 110วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
PART - 1 :SOQL - Salesforce Object Query Language by SREEDHAR
มุมมอง 14614 วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-10 Salesforce Apex Trigger by SREEDHAR
มุมมอง 4514 วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-9 Salesforce Apex Trigger by SREEDHAR
มุมมอง 2214 วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-8 Salesforce Apex Trigger by SREEDHAR
มุมมอง 2014 วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-7 Salesforce Apex Trigger by SREEDHAR
มุมมอง 3414 วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-6 Salesforce Apex Trigger by SREEDHAR
มุมมอง 2314 วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-5 Salesforce Apex Trigger by SREEDHAR
มุมมอง 2314 วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-4 Salesforce Apex Trigger by SREEDHAR
มุมมอง 2314 วันที่ผ่านมา
For more information reach me on Email - sreedharcloud@gmail.com WhatsApp - 917416795462
UC-3 Salesforce Apex Trigger by SREEDHAR
มุมมอง 5414 วันที่ผ่านมา
UC-3 Salesforce Apex Trigger by SREEDHAR
UC-2 Salesforce Apex Trigger by SREEDHAR
มุมมอง 9314 วันที่ผ่านมา
UC-2 Salesforce Apex Trigger by SREEDHAR
UC-1 Salesforce Apex Trigger by SREEDHAR
มุมมอง 24514 วันที่ผ่านมา
UC-1 Salesforce Apex Trigger by SREEDHAR
Salesforce PlatformDeveloper1 Preparation guide by Sreedhar whatsapp:+91-7416795462 Part1
มุมมอง 1165 ปีที่แล้ว
Salesforce PlatformDeveloper1 Preparation guide by Sreedhar whatsapp: 91-7416795462 Part1
Salesforce AppBuilder Preparation Last Minute Guide by Sreedhar91 7416795462 Part4
มุมมอง 515 ปีที่แล้ว
Salesforce AppBuilder Preparation Last Minute Guide by Sreedhar91 7416795462 Part4
Salesforce AppBuilder Preparation Last Minute Guide by Sreedhar91 7416795462 Part3
มุมมอง 255 ปีที่แล้ว
Salesforce AppBuilder Preparation Last Minute Guide by Sreedhar91 7416795462 Part3
Salesforce AppBuilder Preparation Last Minute Guide by Sreedhar(whatsapp):+91- 7416795462 Part2
มุมมอง 305 ปีที่แล้ว
Salesforce AppBuilder Preparation Last Minute Guide by Sreedhar(whatsapp): 91- 7416795462 Part2
Salesforce AppBuilder Preparation Last Minute Guide by Sreedhar(Whatsapp +917416795462) Part1
มุมมอง 715 ปีที่แล้ว
Salesforce AppBuilder Preparation Last Minute Guide by Sreedhar(Whatsapp 917416795462) Part1
SALESFORCE Tab settings in Profile by sreedhar what'sapp+91 7416795462
มุมมอง 2.4K6 ปีที่แล้ว
SALESFORCE Tab settings in Profile by sreedhar what'sapp 91 7416795462
SALESFORCE Inputtext example by sreedhar what's up+91 7416795462
มุมมอง 1196 ปีที่แล้ว
SALESFORCE Inputtext example by sreedhar what's up 91 7416795462
SALESFORCE Trigger scenario 2 by sreedhar what's up +91 7416795462
มุมมอง 2567 ปีที่แล้ว
SALESFORCE Trigger scenario 2 by sreedhar what's up 91 7416795462
SALESFORCE Trigger scenario -1 by sreedhar what's up +917416795462
มุมมอง 2077 ปีที่แล้ว
SALESFORCE Trigger scenario -1 by sreedhar what's up 917416795462
please sir make videos on 3 plus years of experience
@@naresfdc Sure brother
trigger AccountTrigger on Account (after insert, after update) { List<Contact> ConList = new List<Contact>(); for(account acc: Trigger.new){ if(Acc.CountOfContacts__c !=null && Acc.CountOfContacts__c !=0){ for(integer i = 1; i<=Acc.CountOfContacts__c; i++){ contact newcon = new contact(); newcon.accountid = acc.id; newcon.LastName = acc.name + i; ConList.add(newcon); } } } if(!ConList.isempty()){ Try{ insert ConList; }Catch(DmlException e){ system.debug('Error message is'+e.getmessage()); } } }
Document 📄 Download Link - www.linkedin.com/posts/sreedhardevandla_soql-30-exercises-activity-7272947174332612608-Vy2Q?
// Write a trigger to closed the case if createdDate is equal or more than 2 days trigger CasesTrigger on Case (after insert, after update) { List<Case> CaseList = New List<Case>(); for( Case newCase : Trigger.New){ if( newCase.createdDate <= system.now().addDays(-2) && newCase.Status!='closed'){ case updateCase = new Case(); updateCase.id = newCase.id; updateCase.Status = 'closed'; CaseList.add(updateCase); } } if(!CaseList.isempty()){ update CaseList; } }
//Write a trigger to update status of case to closed while insertion and updating ... trigger CaseTrigger on Case (before insert,before update) { for( case newCase : Trigger.New){ if( newCase.status != 'closed'){ newcase.status = 'closed'; } } }
ContactBatch ConBatch = New ContactBatch(); Database.executebatch(ConBatch,200);
AccountBatch AcctBatch = New AccountBatch(); Database.executebatch(AcctBatch,200);
OpportunityBatch OppBatch = New OpportunityBatch(); Database.executebatch(OppBatch,200);
global class ContactBatch implements Database.Batchable<Sobject> { global database.querylocator start ( database.batchablecontext bc){ return database.getquerylocator('select id, homephone from contact where homephone != \'9876543210\''); } global void execute(database.batchablecontext bc,List<Contact> ConList){ for( Contact Con :ConList ){ Con.homephone = '9876543210'; } Update ConList; } global void finish(database.batchablecontext bc){ } }
global class OpportunityBatch implements Database.batchable<Sobject>{ global database.querylocator start (database.batchablecontext bc){ return database.getquerylocator('select id, amount from opportunity where amount!=1000'); } global void execute(database.batchablecontext bc, List<Opportunity> OppList){ for( Opportunity Opps : OppList){ Opps.amount = 1000; } update OppList; } global void finish (database.batchablecontext bc){ } }
Global class AccountBatch implements Database.Batchable<Sobject> { Global Database.querylocator start ( Database.batchablecontext bc){ return Database.getquerylocator('select id, phone from account where phone !=\'9876543210\''); } Global void execute( Database.batchablecontext bc,List<Account> AccList){ for(Account Acc :AccList ){ Acc.Phone = '9876543210'; } update AccList; } Global void finish(Database.batchablecontext bc){ } }
Hi Can you do I one video for map where its id is string and value is list of Account
Sure Brother. i will and update you. Thank you .
@Sreedhar_Salesforce_INDIA can you do today its important
1.MIN() ---> SELECT MIN(AnnualRevenue) FROM Account 2.MAX() ---> SELECT MAX(AnnualRevenue) FROM Account 3.AVG() ---> SELECT AVG(AnnualRevenue) FROM Account 4.SUM() ---> SELECT SUM(AnnualRevenue) FROM Account 5.COUNT() ---> SELECT COUNT(Id) FROM Account 6.Parent To Child ---> SELECT Name, (SELECT Id, FirstName FROM Contacts) FROM Account 7.Child To Parent ---> SELECT Account.Name, COUNT(Id)FROM Contact GROUP BY Account.Name 8.ROll UP() ---> SELECT Industry, COUNT(Id) FROM Account GROUP BY ROLLUP(Industry) 9.ORDER BY ---> SELECT Name FROM Account ORDER BY Name ASC -->(by Default) 10.ORDER BY ---> SELECT Name FROM Account ORDER BY Name DESC 11.GROUP BY ---> SELECT Industry, COUNT(Id) FROM Account GROUP BY Industry 12.HAVING ---> SELECT Name, SUM(AnnualRevenue)FROM Account GROUP BY Name HAVING SUM(AnnualRevenue) > 10000
SELECT Id,Name FROM Account WHERE Name = 'Salesforce' SELECT Id,Name FROM Account WHERE Name != 'Salesforce' SELECT Id, AnnualRevenue FROM Account WHERE AnnualRevenue < 500000 SELECT Id, AnnualRevenue FROM Account WHERE AnnualRevenue > 500000 SELECT Id, AnnualRevenue FROM Account WHERE AnnualRevenue <= 500000 SELECT Id, AnnualRevenue FROM Account WHERE AnnualRevenue >= 500000 SELECT Id, AnnualRevenue, Industry FROM Account WHERE AnnualRevenue > 500000 AND Industry = 'Hospitality' SELECT Id, AnnualRevenue, Industry FROM Account WHERE AnnualRevenue > 500000 OR Industry = 'Hospitality' SELECT Id, AnnualRevenue, Industry FROM Account WHERE (AnnualRevenue > 500000) SELECT Id, AnnualRevenue, Industry FROM Account WHERE NOT IN(AnnualRevenue > 500000) SELECT Id, Industry FROM Account WHERE Industry IN ('Engineering', 'Education') SELECT Id, Industry FROM Account WHERE Industry NOT IN ('Engineering', 'Education') SELECT Id, Name FROM Account WHERE Name LIKE 'A%' SELECT Id, Name FROM Account WHERE Name LIKE '%A' SELECT Id, Name FROM Account WHERE Name LIKE '%A%'
public class AccountTriggerHelper { public static void validatePhone(List<Account> accounts) { for (Account acc : accounts) { if (acc.Phone==null || acc.Phone =='') { // Simplifies null and blank check acc.Phone.addError('Please enter the phone number.'); } } } public static void validateFax(List<Account> accounts) { for (Account acc : accounts) { if (acc.Fax==null || acc.Fax =='') { // Simplifies null and blank check acc.Fax.addError('Please enter the Fax number.'); } } } }
trigger AccountTrigger on Account (before insert) { AccountTriggerHelper.validatePhone(Trigger.new); AccountTriggerHelper.validateFax(Trigger.new); }
trigger LeadsTrigger on Lead (after insert) { // List to store Lead IDs for conversion List<Database.LeadConvert> leadConversions = new List<Database.LeadConvert>(); // Iterate through newly created leads for (Lead leadRecord : Trigger.new) { // Only process leads that are not already converted if (!leadRecord.IsConverted) { // Create a LeadConvert instance for each lead Database.LeadConvert leadConvert = new Database.LeadConvert(); leadConvert.setLeadId(leadRecord.Id); // Set the Lead ID // Specify options for the conversion leadConvert.setDoNotCreateOpportunity(false); // Create an Opportunity leadConvert.setConvertedStatus('Closed - Converted'); // Set status to a valid converted status // Add to the list for batch processing leadConversions.add(leadConvert); } } // Perform the conversion if (!leadConversions.isEmpty()) { List<Database.LeadConvertResult> results = Database.convertLead(leadConversions, false); // Handle any errors during conversion for (Database.LeadConvertResult result : results) { if (!result.isSuccess()) { System.debug('Lead conversion failed: ' + result.getErrors()); } } } }
trigger PreventAccountDeletion on Account (before delete) { // Collect Account IDs from the trigger Set<Id> accountIds = Trigger.oldMap.keySet(); // Query for related Contacts List<Contact> contactList = [ SELECT Id ,AccountId FROM Contact WHERE AccountId IN :accountIds ]; // Create a set of Account IDs that have related Contacts Set<Id> accountsWithContacts = new Set<Id>(); for (Contact con : contactList) { accountsWithContacts.add(con.AccountId); } // Add error only to Accounts with related Contacts for (Account acc : Trigger.old) { if (accountsWithContacts.contains(acc.Id)) { acc.addError('Cannot delete the current account record because it has related contacts.'); } } }
trigger RestrictAccountDeletion on Account (before delete) { // Fetch the profile name of the current user String currentUserProfileName = [SELECT Profile.Name FROM User WHERE Id = :UserInfo.getUserId()].Profile.Name; // Check if the current user's profile is "System Administrator" if (currentUserProfileName == 'System Administrator') { for (Account acc : Trigger.old) { acc.addError('System Administrator do not have permission to delete this Account Record.'); } } }
trigger AccountPhoneToContactTrigger on Account (after update) { // Map to store updated Account Ids and their new Phone values Map<Id, String> accountPhoneMap = new Map<Id, String>(); // Collect updated Accounts where the Phone field has changed for (Account acc : Trigger.new) { Account oldAcc = Trigger.oldMap.get(acc.Id); if (acc.Phone != oldAcc.Phone) { // Check if Phone field has changed accountPhoneMap.put(acc.Id, acc.Phone); } } if (!accountPhoneMap.isEmpty()) { // Query all related Contacts in a single SOQL query List<Contact> contactsToUpdate = [ SELECT Id, Phone, AccountId FROM Contact WHERE AccountId IN :accountPhoneMap.keySet() ]; // Update the Phone field for related Contacts for (Contact contact : contactsToUpdate) { contact.Phone = accountPhoneMap.get(contact.AccountId); } // Perform a single DML update if (!contactsToUpdate.isEmpty()) { update contactsToUpdate; } } }
trigger PreventAccountDeletion on Account (before delete) { // Iterate through the list of Accounts to be deleted for (Account acc : Trigger.old) { // Check if the Active__c field is 'Yes' if (acc.Active__c == 'yes') { // Add a custom error to prevent the deletion acc.addError('Account cannot be deleted because the Active field is set to Yes.'); } } }
trigger UpdateDescriptionOnPhoneChange on Account (before update) { for (Account acc : Trigger.new) { // Check if the phone field has changed if (acc.Phone != Trigger.oldMap.get(acc.Id).Phone) { // Update the description field acc.Description = 'Phone is Updated!'; } } }
trigger AccConTrigger on Account (after insert) { // List to hold new Contact records List<Contact> contactsToCreate = new List<Contact>(); // Loop through each newly inserted Account record for (Account acc : Trigger.new) { // Create a new Contact record associated with the Account Contact newContact = new Contact( LastName = 'Default LastName', // Provide a default last name for the contact AccountId = acc.Id, // Link the Contact to the Account Phone = acc.Phone ); // Add the new Contact to the list contactsToCreate.add(newContact); } // Insert the new Contact records if (!contactsToCreate.isEmpty()) { insert contactsToCreate; } }
Very Informative Sreedhar. Thanks! Please do more videos like that. This one is really helpful
@@lopezdaianaandrea5772 Thank you Daiana,Sure will do more videos
But sir why u not create seperate class for trigger and next for logic purpose
@@dharmeshtayade4856 yes we can
Nice explanation
@@sivasankarChittooru Thank you
pls do more videos
@@siri-i5i Sure Sister
This is really helpful!
Thank you Pragya.
Hii bro plz made videos on soql
good bro carry on
Good one