• Andrew marshal 3
  • NEWBIE
  • 60 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 0
    Replies
How to connect outlook with salesforce . please provide some guidance over it .
Any one please advise me how to write a trigger that will send an email to alert when that record is created or updated or deleted.
Help me to create a validation rule ensures that accounts in the Technology or Finance industries have a minimum Annual Revenue of 1 million, and that accounts with Annual Revenue less than 1 million have an existing opportunity that is not closed or won.
Please create a test class for this 

public with sharing class LeadProcessor {
    
    public static void updateLeadStatus(List<Lead> leadsToUpdate) {
        Set<Id> accountIds = new Set<Id>();
        
        // Loop through the leads and collect the Account Ids
        for (Lead lead : leadsToUpdate) {
            accountIds.add(lead.AccountId);
        }
        
        // Query the related Accounts to check for duplicate leads
        List<Account> relatedAccounts = [SELECT Id, (SELECT Id, Email FROM Leads) FROM Account WHERE Id IN :accountIds];
        
        Map<String, Set<String>> emailToLeadIds = new Map<String, Set<String>>();
        
        // Loop through the related Accounts and Leads and create a map of Email to Lead Ids
        for (Account account : relatedAccounts) {
            for (Lead lead : account.Leads) {
                if (lead.Email != null) {
                    String emailKey = lead.Email.toLowerCase();
                    
                    if (emailToLeadIds.containsKey(emailKey)) {
                        emailToLeadIds.get(emailKey).add(lead.Id);
                    } else {
                        Set<String> leadIds = new Set<String>{lead.Id};
                        emailToLeadIds.put(emailKey, leadIds);
                    }
                }
            }
        }
        
        // Loop through the leads and check for duplicates based on Email
        for (Lead lead : leadsToUpdate) {
            if (lead.Email != null) {
                String emailKey = lead.Email.toLowerCase();
                
                if (emailToLeadIds.containsKey(emailKey) && !emailToLeadIds.get(emailKey).contains(lead.Id)) {
                    lead.addError('This Lead has the same email address as another Lead in the related Account.');
                } else {
                    if (lead.Status == 'New') {
                        lead.Status = 'Open';
                    }
                }
            }
        }
        
        update leadsToUpdate;
    }
    
}
Please help me to write a trigger on opportunity stage and probability to prevent the opportunity stage from giving a lesser value
If the Opportunity Product has a Status of "Shipped" , it checks the Category of the related Product and sets the Final Price based on the following criteria:

If the Category is "Category A", the Final Price is set to 80% of the Unit Price.
If the Category is "Category B", the Final Price is set to 90% of the Unit Price.
If the Category is not "Category A" or "Category B", the Final Price is set to the Unit Price.

If the Opportunity Product does not have a Status of "Shipped", the formula returns the existing value of the Final Price field.
How can we share files with record using flows ?
How Many Times Trigger Execute On An Upsert Event ?
Write a trigger whenever a opportunity stage is changed to closed won , change account rating to Hot.