• janet river
  • NEWBIE
  • 40 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 1
    Replies
What is the lifecycle of an LWC, and how can we use it to manage our component's behavior
?
 
Hello , How do we communicate between LWCs in the same component hierarchy?
Help me to create a trigger that will prevent cases from being created for expired products.
Help me to  Create a apex class that notifies the admin whenever a task or event is created on standard objects
Help me to create a trigger on Sobject that whenever a file is uploaded an email should be send to all system admin users .
Please help me to create a test class .

This class Converts a lead into an opportunity and sends an email notification to the owner of the newly created opportunity

public class LeadConversionWithEmailNotification {
    public static void convertLeadToOpportunity(Id leadId) {
        Database.LeadConvert lc = new Database.LeadConvert();
        lc.setLeadId(leadId);

        // Set opportunity details
        lc.setOpportunityName('New Opportunity');
        lc.setCloseDate(Date.today().addDays(30));
        lc.setStage('Prospecting');

        // Convert the lead
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        Opportunity opp = [SELECT Id, OwnerId FROM Opportunity WHERE Id = :lcr.getOpportunityId()];

        // Send email to the opportunity owner
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setToAddresses(new List<String>{Userinfo.getUserEmail(opp.OwnerId)});
        email.setSubject('New Opportunity Created');
        email.setPlainTextBody('A new opportunity has been created with the name ' + opp.Name);
        Messaging.sendEmail(new List<Messaging.Email>{email});
    }
}

To use this Apex class, I have call the convertLeadToOpportunity method with the ID of the lead we want to convert 

Id leadId = '00Qxxxxxxxxxxxx';
LeadConversionWithEmailNotification.convertLeadToOpportunity(leadId);
Help me to create a trigger on Sobject that whenever a file is uploaded an email should be send to all system admin users .