• Shruthi MN 88
  • NEWBIE
  • 40 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 34
    Questions
  • 22
    Replies
Develop a Lightning component that allows users to mass update the close date on opportunities. 
Integrate this component into the Opportunity List View page and allow for bulk updates. The opportunities should be selected from the standard list view and on clikc of a butoon iit should navigate to another page where the opportunity close date gets updated and display the result . The code is not working as expected. Opportunity close date is not egtting udpated
This is the controller:
public with sharing class OpportunityUpdateController {
 @AuraEnabled(cacheable=true)
    public static void updateOpportunities(List<Id> opportunityIds, String newCloseDate) {
        List<Opportunity> opportunitiesToUpdate = new List<Opportunity>();

        for (Id oppId : opportunityIds) {
            Opportunity opp = new Opportunity(Id = oppId);
            opp.CloseDate = Date.valueOf(newCloseDate);
            opportunitiesToUpdate.add(opp);
            system.debug('opportunitiesToUpdate:' +opportunitiesToUpdate);
        }

        update opportunitiesToUpdate;
    }
}
This is the html code

<template>
    <lightning-card title="Mass Update Close Date">
        <div class="slds-p-around_medium">
            <lightning-input type="date" label="New Close Date" value={newCloseDate} onchange={handleDateChange}></lightning-input>
            <lightning-button label="Update Close Date" onclick={updateCloseDate} variant="brand"></lightning-button>
        </div>
        <lightning-datatable
            key-field="Id"
            data={opportunities}
            columns={columns}
            selected-rows={selectedOpportunities}
            onrowselection={handleRowSelection}
        >
        </lightning-datatable>
    </lightning-card>
</template>
this is the js code
import { LightningElement, api, track } from 'lwc';
import updateOpportunities from '@salesforce/apex/OpportunityUpdateController.updateOpportunities';
const columns = [
    { label: 'Opportunity Name', fieldName: 'Name' },
    { label: 'Close Date', fieldName: 'CloseDate', type: 'date' }
];
export default class massUpdateOpportunityCloseDate extends LightningElement {
    @api opportunities;
    @track newCloseDate;
    @track columns = columns;
    @track selectedOpportunities = [];
    @track updateMessage = '';
    handleDateChange(event) {
        this.newCloseDate = event.target.value;
        console.log('New Close Date:', this.newCloseDate);
    }
    handleRowSelection(event) {
        this.selectedOpportunities = event.detail.selectedRows;
        console.log('Selected Opportunities:', this.selectedOpportunities);
    }
    updateCloseDate() {
        if (!this.newCloseDate || this.selectedOpportunities.length === 0) {
            this.updateMessage = 'Please select opportunities and provide a valid new close date.';
            return;
        }
        const opportunityIds = this.selectedOpportunities.map(opp => opp.Id);
        console.log('Opportunity IDs:', opportunityIds);
        updateOpportunities({ opportunityIds: opportunityIds, newCloseDate: this.newCloseDate })
            .then(result => {
               
                this.updateMessage = 'Opportunities updated successfully.';
                console.log('Update Result:', result);
            })
            .catch(error => {
               
                this.updateMessage = 'Error updating opportunities: ' + JSON.stringify(error);
                console.error('Update Error:', error);
            });
    }
}
 

Create a simple To-Do List application using Lightning Web Components (LWC). The application should consist of two LWCs: one for adding tasks and one for displaying the list of tasks. Use a component event to pass data (tasks) from the task addition component to the task list component. 
The task is not getting updated in the tasklist
task addition.html
 
<template>
    <lightning-card title="Add Task">
        <div class="slds-m-around_medium">
            <lightning-input label="Task Name" value={taskName} onchange={handleTaskNameChange}></lightning-input>
            <lightning-button label="Add" onclick={addTask}></lightning-button>
        </div>
    </lightning-card>
</template>
task addition .js
import { LightningElement, track } from 'lwc';
export default class TaskAddition extends LightningElement {
    @track taskName = '';
    handleTaskNameChange(event) {
        this.taskName = event.target.value;
    }
    addTask() {
        if (this.taskName) {
            // Fire a custom event with the task name as the detail
            const taskEvent = new CustomEvent('taskadded', {
                detail: this.taskName
            });
            this.dispatchEvent(taskEvent);
            this.taskName = ''; // Clear the input field
        }
    }
}
 
Taks addition .xml
 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>58.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>
 
pubsub.js
const listeners = {};
export function registerListener(eventName, callback, thisArg) {
    if (!listeners[eventName]) {
        listeners[eventName] = [];
    }
    listeners[eventName].push({ callback, thisArg });
}
export function unregisterAllListeners(thisArg) {
    for (const eventName in listeners) {
        listeners[eventName] = listeners[eventName].filter(listener => listener.thisArg !== thisArg);
    }
}
export function fireEvent(eventName, eventData) {
    if (listeners[eventName]) {
        listeners[eventName].forEach(listener => {
            try {
                listener.callback.call(listener.thisArg, eventData);
            } catch (error) {
                console.error(`Error in handling event ${eventName}: ${error}`);
            }
        });
    }
}
task added event js
import { LightningElement } from 'lwc';
export default class TaskAddedEvent extends LightningElement {}
const taskAddedEvent = new Event('taskadded');
export { taskAddedEvent };
Tasklist.html
<template>
    <lightning-card title="Task List">
        <div class="slds-m-around_medium">
            <ul class="slds-list_ordered">
                <!-- Loop through tasks and display them -->
                <template for:each={tasks} for:item="task">
                    <li key={task.id}>{task.name}</li>
                </template>
            </ul>
        </div>
    </lightning-card>
</template>
tasklist.js
 
import { LightningElement, track } from 'lwc';
import { registerListener, unregisterAllListeners } from 'c/pubsub';
export default class TaskList extends LightningElement {
    @track tasks = [];
    connectedCallback() {
        // Subscribe to the custom event 'taskadded'
        registerListener('taskadded', this.handleTaskAdded, this);
    }
    disconnectedCallback() {
        // Unsubscribe from the custom event when the component is destroyed
        unregisterAllListeners(this);
    }
    handleTaskAdded(event) {
        const newTask = event.detail;
        console.log('Received task:', newTask);
        // Add the new task to the list
        this.tasks = [this.tasks, newTask];
}
}
tasklist.xml
 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>58.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>
Show Less
1- Write a batch class to update leads status as closed lost if no activity has been performed for last 30 days and send notification to manager
I am getting the attached wrrorUser-added image
global class UpdateLeadStatusBatch implements Database.Batchable<sObject> {

    global Database.QueryLocator start(Database.BatchableContext BC) {
        DateTime thirtyDaysAgo = System.now().addDays(-30);
        String query = 'SELECT Id, OwnerId, Owner.ManagerId__c FROM Lead WHERE LastActivityDate <= :thirtyDaysAgo AND Status != \'Closed - Lost\'';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope) {
        List<Lead> leadsToUpdate = new List<Lead>();
        Set<Id> managerIds = new Set<Id>();

        for (sObject s : scope) {
            Lead lead = (Lead) s;
            lead.Status = 'Closed - Lost';
            leadsToUpdate.add(lead);

            // Access the manager's Id through the custom field
            Id managerId = (Id)lead.get('Owner.ManagerId__c');
            if (managerId != null) {
                managerIds.add(managerId);
            }
        }

        update leadsToUpdate;

        // Send Notification to Managers
        // Using Email Services to send email notifications
        if (!managerIds.isEmpty()) {
            List<Messaging.SingleEmailMessage> emailMessages = new List<Messaging.SingleEmailMessage>();

            for (Id managerId : managerIds) {
                // Construct and send email to the manager
                User managerUser = [SELECT Id, Email FROM User WHERE Id = :managerId LIMIT 1];

                if (managerUser != null && !String.isBlank(managerUser.Email)) {
                    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                    email.setSubject('Lead Status Update');
                    email.setHtmlBody('<p>Hello, ' + managerUser.Name + ',</p>' +
                                      '<p>The status of some leads has been updated to "Closed - Lost" due to inactivity.</p>' +
                                      '<p>Thank you!</p>');
                    email.setTargetObjectId(managerUser.Id);
                    email.setSaveAsActivity(false);
                    emailMessages.add(email);
                }
            }

            if (!emailMessages.isEmpty()) {
                List<Messaging.SendEmailResult> sendResults = Messaging.sendEmail(emailMessages);
                for (Messaging.SendEmailResult result : sendResults) {
                    if (!result.isSuccess()) {
                        System.debug('Failed to send email: ' + result.getErrors()[0].getMessage());
                    }
                }
            }
        }
    }

    global void finish(Database.BatchableContext BC) {
        // Any logic you want to execute after the batch finishes
    }
}
 
Develop a trigger that sends an email notification to the account owner when a high-priority case is created or updated.

I have written the below code but email is not getting fired 

public class CaseEmailNotificationHandler {
    public static void sendEmailNotifications(List<Case> casesToUpdate) {
        List<Messaging.SingleEmailMessage> emailMessages = new List<Messaging.SingleEmailMessage>();
 
        // Collect Account Owner Ids for high-priority cases and fetch User information
        Map<Id, User> accountOwners = new Map<Id, User>();
        
        for (Case updatedCase : casesToUpdate) {
            if (updatedCase.Priority == 'High') {
                Id ownerId = updatedCase.Account.OwnerId;
                
                // Check if the ownerId has not been processed already
                if (!accountOwners.containsKey(ownerId)) {
                    List<User> owners = [SELECT Id, Name, Email FROM User WHERE Id = :ownerId LIMIT 1];
                    if (!owners.isEmpty()) {
                        accountOwners.put(ownerId, owners[0]);
                    } else {
                        System.debug('No User found for ownerId: ' + ownerId);
                    }
                }
 
                User accountOwner = accountOwners.get(ownerId);

                if (accountOwner != null && !String.isBlank(accountOwner.Email)) {
                    // Create email message
                    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                    email.setSubject('High-Priority Case Notification');
                    email.setHtmlBody('<p>Hello, ' + accountOwner.Name + ',</p>' +
                                      '<p>A high-priority case has been created or updated. Please review the details.</p>' +
                                      '<p>Case Number: ' + updatedCase.CaseNumber + '</p>' +
                                      '<p>Case Subject: ' + updatedCase.Subject + '</p>' +
                                      '<p>Priority: ' + updatedCase.Priority + '</p>' +
                                      '<p>Thank you!</p>');
                    email.setTargetObjectId(accountOwner.Id);
                    email.setSaveAsActivity(false);
                    emailMessages.add(email);
                } else {
                    System.debug('Email not sent due to missing or invalid recipient for case Id: ' + updatedCase.Id);
                }
            }
        }
         
        if (!emailMessages.isEmpty()) {
            List<Messaging.SendEmailResult> sendResults = Messaging.sendEmail(emailMessages);
            for (Messaging.SendEmailResult result : sendResults) {
                if (!result.isSuccess()) {
                    System.debug('Failed to send email: ' + result.getErrors()[0].getMessage());
                }
            }
        }
    }
}
trigger CaseEmailNotificationTrigger on Case (after insert, after update) {
    if (Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)) {
        CaseEmailNotificationHandler.sendEmailNotifications(Trigger.new);
    }
}
Can you help me wirte a handler class for the below senario

            5. On account record deletion store that record in Backup object.

Create a new object Backup. In that create Long Text field - Record Backup.

Only those fields that have values must be saved in this with their fieldname and fieldvalue, also save Name of user who created this record and with createddate, lastmodified date.Each field value must start on new line.




trigger createBackup on Account (after delete) 
{
 if(trigger.isDelete && trigger.isAfter)
 {
  List<My_Backup__c> lstToInsrt = new List<My_Backup__c>();  
  for(Account deletedAcc : trigger.old)
  {
   system.debug('deletedAcc '+deletedAcc );
   My_Backup__c backup = new My_Backup__c();
   backup.Name = deletedAcc.name;
   lstToInsrt.add(backup);
   system.debug('backup '+backup);
  }
  if(lstToInsrt.size()>0)
  {
   insert lstToInsrt;
   system.debug('list'+lstToInsrt);
  }
 }
}
Can you help me write a handler class for the below code
 

         4. Send email when the Lead Owner changes. Send email to the new lead owner and keep your respective Mentors in Cc of email.

( email body must have proper contain )


public class SendEmailHandler {
    List<Messaging.SingleEmailMessage> mails = 
  new List<Mesaging.SingleEmailMessage>();
    {
  for (Lead mylead : Trigger.new) {
    if (mylead.Email != null && mylead.FirstName != null) {
    
      Messaging.SingleEmailMessage mail = 
      new Messaging.SingleEmailMessage();
    
      
      List<String> sendTo = new List<String>();
      sendTo.add(mylead.Email);
      mail.setToAddresses(sendTo);
    
      // Step 3: Set who the email is sent from
      mail.setReplyTo('abc@gmail.com');
      mail.setSenderDisplayName('Lead has been created');
    
      // (Optional) Set list of people who should be CC'ed
      List<String> ccTo = new List<String>();
      ccTo.add('abc@gmail.com');
      mail.setCcAddresses(ccTo);

      // Step 4. Set email contents - you can use variables!
      mail.setSubject('Lead Owner has been changed');
      String body = 'Dear ' + mylead.FirstName + ', ';
      body += 'The Lead owner has been changed';
      body += 'Please take care of the lead';
      
      mail.setHtmlBody(body);
    
      // Step 5. Add your email to the master list
      mails.add(mail);
    }
  }
  // Step 6: Send all emails in the master list
  Messaging.sendEmail(mails);
}

}
Can you help complete the below code along with trigger
 

  3. Automate approval process on Quote ( created in previous tasks ) using trigger.

Check approval criteria in trigger.



public class ApprovalProcessHandler {
    public static void approval(){
        Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setObjectId('0055j000009sbROAAY');
//If the next step in your approval process is another Apex approval process, you specify exactly one user ID as the next approver. 
//If not, you cannot specify a user ID and this method must be null.
//req.setNextApproverIds(null);
Approval.ProcessResult processResult = Approval.process(req);
//Valid values are: Approved, Rejected, Removed or Pending.
System.assertequals('Draft', + processResult.getInstanceStatus());
    }
    
}
Can you help me with the below code

 

Note - All Trigger must have a handler.

 

1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.

Create GST (percentage) fields on Product.


Note - All Trigger must have a handler.

 

1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.

Create GST (percentage) fields on Product.


Note - All Trigger must have a handler.

 

1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.

Create GST (percentage) fields on Product.


 
Hi Everyone,

Can you help be with the below code:
1. Create an Account Record with Name =”Eternus”. Create associated contacts. Create a Custom field called Contact Count on Account . Query on Contact
where Account.Name =”Eternus” and count the associated contacts. Update the custom field on Accounts with that count..

I am not getting the count of the records:

public class Accassoccon {
    public static void accountacc(){
        Account a = new Account();
        a.Name = 'Eternus';
        Database.insert(a,false);
        system.debug('The inserted account is:' +a);
       list<Account > recordIDs = new   list<Account >();
List<Account> accountlist1 = [Select Id, ContactCount__c, (Select Id From Contacts) From Account where Id =: recordIDs];  //get a list of the corresponding accounts
for(Account account : accountlist1) {
    
    if(account.Contacts == null) continue;
    
    account.ContactCount__c = account.Contacts.size();
}

Database.update(accountList1,false);        
    }

}
Use a validation rule on Account where OpportunityChild__c object gets created only one.OpportunityChild__c is the parent object and Account is th child. Account has a rollup count summary feild as OpportunityCount__c. The validation rule works. Incase they deactivate the validation rule and add 6 records then the validation dosent work

OpportunityCount__c  = 2
Hi Everyone,
Can you write these codes for me?

2.Create a Bike class with printBikeColor() method and create two child class which overrides printBikeColor()
3.Create a StringAppender class and create two overloading methods .Method behaviour is to concatenate the given input strings.
4.Create a class name 'Parent' which has two methods showSurname() and showProperty()
  create a subclass 'Chile' which inherits only showProperty() method. 
5. In the first point Employee class. include a variable called salary and value must not be negative. Encapsulate salary variable with method.
6. Write executable code of above examples. 
HI Everyone ,

Can you help me write this code?
1.Create Employee class with three variables(name ,role,roleDescription) and one method(showEmployeeInfo()--> which prints employee data).
   Create two Objects and set those variable and execute that one method
2.Create a Bike class with printBikeColor() method and create two child class which overrides printBikeColor()
3.Create a StringAppender class and create two overloading methods .Method behaviour is to concatenate the given input strings.
4.Create a class name 'Parent' which has two methods showSurname() and showProperty()
  create a subclass 'Chile' which inherits only showProperty() method. 
5. In the first point Employee class. include a variable called salary and value must not be negative. Encapsulate salary variable with method.
6. Write executable code of above examples.  
HI Everyone,

Can you help me design this page?
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta name="generator" content="Aspose.Words for .NET 23.8.0" />
      <title></title>
      <style type="text/css">body { font-family:'Times New Roman'; font-size:12pt;
  
    
 }p { margin:0pt }
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

li {
  display: inline;
}

 
</style>
   </head>
   <body>
      <div  >

         <p style="margin-top:11.25pt; margin-left:133.05pt; text-align:justify; line-height:34.15pt"><span style="font-family:Calibri; font-size:28pt">The</span><span style="font-family:Calibri; font-size:28pt; letter-spacing:6.45pt"> </span><span style="font-family:Calibri; font-size:28pt">Dental</span><span style="font-family:Calibri; font-size:28pt; letter-spacing:5.1pt"> </span><span style="font-family:Calibri; font-size:28pt">Hygiene</span><span style="font-family:Calibri; font-size:28pt; letter-spacing:7.55pt"> </span><span style="font-family:Calibri; font-size:28pt">Association</span></p>
<img src="img_girl.jpg" alt="Girl in a jacket" width="100" height="40" >

         <p style="margin-top:6.5pt; margin-right:479.05pt; text-indent:0.65pt; line-height:8pt"><span style="font-family:Calibri; font-size:8pt" >The Dental Hygiene</span></p>
<img src="image/your-image.png" width="300"  style="float: right" />
     <p style="margin-top:7.1pt; margin-left:32.1pt; text-align:justify; line-height:15.85pt"><span style="font-family:Calibri; font-size:13pt">Home</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:52.4pt"> </span><span style="font-family:Calibri; font-size:13pt">Adults</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:59.8pt"> </span><span style="font-family:Calibri; font-size:13pt">Kids</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:61.25pt"> </span><span style="font-family:Calibri; font-size:13pt">News</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:60.9pt"> </span><span style="font-family:Calibri; font-size:13pt">FAQ</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:50.85pt"> </span><span style="font-family:Calibri; font-size:13pt">Glossary</span></p>

         <p style="margin-top:15.55pt; margin-left:259.55pt; text-align:justify; line-height:26.85pt"><span style="font-family:Calibri; font-size:22pt">Kids</span></p>

         <p style="margin-top:23.4pt; margin-right:219.3pt; margin-left:13.1pt; text-indent:0.65pt; line-height:12.45pt"><span style="font-family:Calibri; font-size:9pt">Bringing</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.9pt"> </span><span style="font-family:Calibri; font-size:9pt">up</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.95pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">child</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">with</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.05pt"> </span><span style="font-family:Calibri; font-size:9pt">proper</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.5pt"> </span><span style="font-family:Calibri; font-size:9pt">attention</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.5pt"> </span><span style="font-family:Calibri; font-size:9pt">to</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.35pt"> </span><span style="font-family:Calibri; font-size:9pt">their</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">oral</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.05pt"> </span><span style="font-family:Calibri; font-size:9pt">health</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.9pt"> </span><span style="font-family:Calibri; font-size:9pt">a lifelong</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.25pt"> </span><span style="font-family:Calibri; font-size:9pt">investment</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.55pt"> </span><span style="font-family:Calibri; font-size:9pt">in</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1pt"> </span><span style="font-family:Calibri; font-size:9pt">their</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.85pt"> </span><span style="font-family:Calibri; font-size:9pt">health,</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.2pt"> </span><span style="font-family:Calibri; font-size:9pt">which</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.75pt"> </span><span style="font-family:Calibri; font-size:9pt">will</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.05pt"> </span><span style="font-family:Calibri; font-size:9pt">benefit</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.85pt"> </span><span style="font-family:Calibri; font-size:9pt">them</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">greatly for</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.4pt"> </span><span style="font-family:Calibri; font-size:9pt">the</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">rest</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.8pt"> </span><span style="font-family:Calibri; font-size:9pt">of</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">their</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">lives.</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.1pt"> </span><span style="font-family:Calibri; font-size:9pt">Early</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">childhood</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">cavities</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.05pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">a</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.85pt"> </span><span style="font-family:Calibri; font-size:9pt">disease</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3pt"> </span><span style="font-family:Calibri; font-size:9pt">that can</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.5pt"> </span><span style="font-family:Calibri; font-size:9pt">ruin</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.3pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">child’s</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.35pt"> </span><span style="font-family:Calibri; font-size:9pt">teeth,</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.2pt"> </span><span style="font-family:Calibri; font-size:9pt">even</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.85pt"> </span><span style="font-family:Calibri; font-size:9pt">into</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.75pt"> </span><span style="font-family:Calibri; font-size:9pt">adulthood,</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.8pt"> </span><span style="font-family:Calibri; font-size:9pt">but</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.9pt"> </span><span style="font-family:Calibri; font-size:9pt">it</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.4pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.9pt"> </span><span style="font-family:Calibri; font-size:9pt">easily preventable.</span></p>
   

   <p  style="margin-top:2.6pt; margin-right:226.55pt; margin-left:13.1pt; line-height:12.45pt"><span style="font-family:Calibri; font-size:9pt">There</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.95pt"> </span><span style="font-family:Calibri; font-size:9pt">are</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.75pt"> </span><span style="font-family:Calibri; font-size:9pt">a</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.85pt"> </span><span style="font-family:Calibri; font-size:9pt">wide</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.25pt"> </span><span style="font-family:Calibri; font-size:9pt">variety</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.3pt"> </span><span style="font-family:Calibri; font-size:9pt">of</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.6pt"> </span><span style="font-family:Calibri; font-size:9pt">steps</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.95pt"> </span><span style="font-family:Calibri; font-size:9pt">you</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.1pt"> </span><span style="font-family:Calibri; font-size:9pt">can</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.5pt"> </span><span style="font-family:Calibri; font-size:9pt">take</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.4pt"> </span><span style="font-family:Calibri; font-size:9pt">to</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.35pt"> </span><span style="font-family:Calibri; font-size:9pt">teach</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.55pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">child good</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.8pt"> </span><span style="font-family:Calibri; font-size:9pt">dental</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">habits,</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.5pt"> </span><span style="font-family:Calibri; font-size:9pt">and</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.25pt"> </span><span style="font-family:Calibri; font-size:9pt">one</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.7pt"> </span><span style="font-family:Calibri; font-size:9pt">of</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.6pt"> </span><span style="font-family:Calibri; font-size:9pt">the</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">best</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.9pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">leading</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.8pt"> </span><span style="font-family:Calibri; font-size:9pt">by</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.95pt"> </span><span style="font-family:Calibri; font-size:9pt">example. Make</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.3pt"> </span><span style="font-family:Calibri; font-size:9pt">sure</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.4pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">child</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.2pt"> </span><span style="font-family:Calibri; font-size:9pt">knows</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.95pt"> </span><span style="font-family:Calibri; font-size:9pt">how</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.05pt"> </span><span style="font-family:Calibri; font-size:9pt">much</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.75pt"> </span><span style="font-family:Calibri; font-size:9pt">importance</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.25pt"> </span><span style="font-family:Calibri; font-size:9pt">you</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.1pt"> </span><span style="font-family:Calibri; font-size:9pt">place</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.85pt"> </span><span style="font-family:Calibri; font-size:9pt">on dental</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.8pt"> </span><span style="font-family:Calibri; font-size:9pt">health</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">so</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.5pt"> </span><span style="font-family:Calibri; font-size:9pt">they</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.65pt"> </span><span style="font-family:Calibri; font-size:9pt">know</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">that</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.55pt"> </span><span style="font-family:Calibri; font-size:9pt">it</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.05pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.9pt"> </span><span style="font-family:Calibri; font-size:9pt">something</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.5pt"> </span><span style="font-family:Calibri; font-size:9pt">to</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.35pt"> </span><span style="font-family:Calibri; font-size:9pt">be</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.55pt"> </span><span style="font-family:Calibri; font-size:9pt">valued. Brushing</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.95pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">teeth</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.15pt"> </span><span style="font-family:Calibri; font-size:9pt">along</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">with</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.4pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.9pt"> </span><span style="font-family:Calibri; font-size:9pt">child</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">and</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.25pt"> </span><span style="font-family:Calibri; font-size:9pt">letting</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.85pt"> </span><span style="font-family:Calibri; font-size:9pt">them</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">follow your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.9pt"> </span><span style="font-family:Calibri; font-size:9pt">lead</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.4pt"> </span><span style="font-family:Calibri; font-size:9pt">can</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.5pt"> </span><span style="font-family:Calibri; font-size:9pt">be</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.55pt"> </span><span style="font-family:Calibri; font-size:9pt">really</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.75pt"> </span><span style="font-family:Calibri; font-size:9pt">helpful</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.25pt"> </span><span style="font-family:Calibri; font-size:9pt">in</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1pt"> </span><span style="font-family:Calibri; font-size:9pt">setting</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.7pt"> </span><span style="font-family:Calibri; font-size:9pt">up</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.95pt"> </span><span style="font-family:Calibri; font-size:9pt">the</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> <</span><span style="font-family:Calibri; font-size:9pt">habit</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.05pt"> /span><span style="font-family:Calibri; font-size:9pt">of</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.6pt"> </span><span style="font-family:Calibri; font-size:9pt">teeth brushing</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.45pt"> </span><span style="font-family:Calibri; font-size:9pt">in</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"></span><span style="font-family:Calibri; font-size:9pt">child’s</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3pt">  </span></p>
   
      </div>
   </body>
</html>
User-added image
HI Everyone,

Can you help me with the webpage by using html and cass .
<html>
<head>
<img src="dentai1.jpeg"  width="40" height="40">
<h1>The Dental Hyginene Association</h1>
<style>


ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

li {
  display: inline;
}


</style>
</head>
<body>
<ul>
  <li><a href="#home">Home</a></li>
  <li><a href="#news">Adults</a></li>
  <li><a href="#contact">Kids</a></li>
  <li><a href="#about">News</a></li>
   <li><a href="#about">FAQ</a></li>
    <li><a href="#about">Glossary</a></li>
</ul>

<div class="myDiv">
  
</div>
<p>

<div class="myDiv">

It consists of the study, diagnosis, prevention, management, and treatment of diseases, disorders, and conditions of the mouth, most commonly focused on dentition (the development and arrangement of teeth) as well as the oral mucosa.
 <img src="dentai1.jpeg"  width="40" height="40">
</div>



</body>
</html>User-added image
HI Everyone,

I need to create a webpage similar to the attached image by using html and css.LOgin page should redirect to this page
Ligin page
<html>
<head>
<img src="dentai1.jpeg"  width="40" height="40">
<h1>The Dental Hyginene Association</h1>
<style>


ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

li {
  display: inline;
}

Webite code
</style>
</head>
<body>
<ul>
  <li><a href="#home">Home</a></li>
  <li><a href="#news">Adults</a></li>
  <li><a href="#contact">Kids</a></li>
  <li><a href="#about">News</a></li>
   <li><a href="#about">FAQ</a></li>
    <li><a href="#about">Glossary</a></li>
</ul>

<div class="myDiv">
  
</div>
<p>

<div class="myDiv">

It consists of the study, diagnosis, prevention, management, and treatment of diseases, disorders, and conditions of the mouth, most commonly focused on dentition (the development and arrangement of teeth) as well as the oral mucosa.
 <img src="dentai1.jpeg"  width="40" height="40">
</div>



</body>
</html>
<html>
<head>
<img src="dentai1.jpeg"  width="40" height="40">
<h1>The Dental Hyginene Association</h1>
<style>


ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

li {
  display: inline;
}


</style>
</head>
<body>
<ul>
  <li><a href="#home">Home</a></li>
  <li><a href="#news">Adults</a></li>
  <li><a href="#contact">Kids</a></li>
  <li><a href="#about">News</a></li>
   <li><a href="#about">FAQ</a></li>
    <li><a href="#about">Glossary</a></li>
</ul>

<div class="myDiv">
  
</div>
<p>

<div class="myDiv">

It consists of the study, diagnosis, prevention, management, and treatment of diseases, disorders, and conditions of the mouth, most commonly focused on dentition (the development and arrangement of teeth) as well as the oral mucosa.
 <img src="dentai1.jpeg"  width="40" height="40">
</div>



</body>
</html>
Hi Everyone,

I have written a html code but I dont know how to add the color. Attached is the page which has to be designed for your reference:


<html>
  <head>
<style>
<style>
table {
th
    {
      background-color:yellow;
      color:black;
    }
}
</style>
  </head>
  <body> 
  <table border="2" width=50% height= 50%>
    <tr> 

    <th colspan ="7" >Timetable</th>  

    </tr> 
    <tr> 
    <th rowspan ="7" >Hours</th> 
<th> Days/Periods</th> 
    <th> Mon</th> 
    <th> Tue</th> 
    <th> Wed</th> 
    <th> Thurs</th> 
    <th> Fri</th> 
    </tr> 
    <tr> 
    <td>10:00 to 11:00 </td> 
    <td>Science</td>
    <td>Maths</td>
    <td>Science</td> 
    <td>Maths</td> 
   <td>English</td> 
    </tr> 
    <tr> 
    <td>11:00 to 12:00</td> 
    <td>Science</td>
    <td>Maths</td>
    <td>Science</td> 
    <td>Maths</td> 
   <td>English</td> 
    </tr> 
    <tr> 
    <th colspan="5">Lunch</th> 
    </tr> 
    <tr> 
    <td>12:00 to 14:00</td> 
    <<td>Science</td>
    <td>Maths</td>
    <td>Science</td> 
    <td>Maths</td> 
    <td rowspan="2">Project</td>
    </tr> 
    <tr> 
    <td>14:00 to 15:00</td> 
    <<td>Science</td>
    <td>Maths</td>
    <td>Science</td> 
    <td>Maths</td>  
    </tr> 
     
    
  </body>
</html>


User-added image
HI Everyone,

I have written the below code :
 
Can you write map instead of a list  . Instead of two for loops pass maps:
 
public class HelperAccount{
    public static void helpaccmethod(List<account> oldAccount, List<account> newAccount){
        List<contact> conList=[select lastname,otherphone,accountid,phone from contact 
                               where accountid IN: newAccount];
        map<id,string> oldAccidVsPhone= new map<id,string>();
        map<id,string> newAccidVsPhone= new map<id,string>();
        for(account newAcc: newAccount){
            for(account oldAcc: oldAccount){
                if(newAcc.phone!=oldAcc.phone && oldAcc.id==newAcc.id){
                    oldAccidVsPhone.put(oldAcc.id,oldAcc.phone);
                    newAccidVsPhone.put(newAcc.id,newAcc.phone);
                }
            }
        }
        list<contact> updateContactList= new List<contact>();
for(contact con: conList){
            if(oldAccidVsPhone.containskey(con.accountid)){
                con.phone=oldAccidVsPhone.get(con.accountid);
                con.Phone=newAccidVsPhone.get(con.accountid);
                updateContactList.add(con);
            }
        }
        if(updateContactList.size()>0){
            update updateContactList;
        }
    }
}
 
Trigger:
 
trigger UpdateAccount on Account (before update,after update) {
    if(trigger.isUpdate && trigger.isBefore){
        HelperAccount.helpaccmethod(trigger.old,trigger.new);
    }
}
HI Everyone,

I have written a handler class and a trigger on the below senario. Code is not working

Created two feilds on Contact Ratilg__c and Site__c. Now once a contact is created the contact should search for the site name of the account which is entered on site__c  of the contact and associat the account with the contact. Then update the accounts Rating feild  as per the contact Rating__c feild.

Below is the code that I have written

Handl;er class

public class ContactTriggerHandler {
    public static void handleAfterInsert(List<Contact> newContacts) {
        Map<String, String> contactSiteRatingMap = new Map<String, String>();
        for (Contact newContact : newContacts) {
            if(newContact.AccountId == null && newContact.Site__c != null && newContact.Rating__c != null){
                contactSiteRatingMap.put(newContact.Site__c, newContact.Rating__c);
            }
        }
        if (!contactSiteRatingMap.isEmpty()) {
            List<Account> matchingAccounts = [SELECT Id, Site, Rating FROM Account
                                              WHERE Site IN :contactSiteRatingMap.keySet() AND 
                                              Rating IN :contactSiteRatingMap.values()];
            List<Contact> contactsToUpdate = new List<Contact>();
            for (Contact newContact : newContacts) {
                if (newContact.AccountId == null && newContact.Site__c != null && newContact.Rating__c != null) {
                    for (Account matchingAccount : matchingAccounts) {
                        if (newContact.Site__c == matchingAccount.Site && newContact.Rating__c == matchingAccount.Rating) {
                            newContact.AccountId = matchingAccount.Id;
                            contactsToUpdate.add(newContact);     
                        }
                    } 
                }
            }
            if (!contactsToUpdate.isEmpty()) {
                
                update contactsToUpdate;                
            }
        }  
    }  


Trigger
trigger ContactTrigger on Contact(after insert)
{
    ContactTriggerHandler.handleAfterInsert(Trigger.new);
}
Hi Everyone,

I have to write a handler class and a trigger on the below senario

Create two feilds on Contact Ratilg__c and Site__c. NOw once a contact is created or updated the contact should search for the site name of the attacunt which is entered on site__c  of the oncate and associated the account with the contact. Then update the accounts Rating feild  as per the contact Rating__c feild.

Below is the code that I have written

Handl;er class

public class ContactTriggerHandler {
    public static void handleAfterInsert(List<Contact> newContacts) {
        Map<String, String> contactSiteRatingMap = new Map<String, String>();
        for (Contact newContact : newContacts) {
            if(newContact.AccountId == null && newContact.Site__c != null && newContact.Rating__c != null){
                contactSiteRatingMap.put(newContact.Site__c, newContact.Rating__c);
            }
        }
        if (!contactSiteRatingMap.isEmpty()) {
            List<Account> matchingAccounts = [SELECT Id, Site, Rating FROM Account
                                              WHERE Site IN :contactSiteRatingMap.keySet() AND 
                                              Rating IN :contactSiteRatingMap.values()];
            List<Contact> contactsToUpdate = new List<Contact>();
            for (Contact newContact : newContacts) {
                if (newContact.AccountId == null && newContact.Site__c != null && newContact.Rating__c != null) {
                    for (Account matchingAccount : matchingAccounts) {
                        if (newContact.Site__c == matchingAccount.Site && newContact.Rating__c == matchingAccount.Rating) {
                            newContact.AccountId = matchingAccount.Id;
                            contactsToUpdate.add(newContact);     
                        }
                    } 
                }
            }
            if (!contactsToUpdate.isEmpty()) {
                
                update contactsToUpdate;                
            }
        }  
    }  


Trigger
trigger ContactTrigger on Contact(after insert)
{
    ContactTriggerHandler.handleAfterInsert(Trigger.new);
}

 
Hi Everyone,

I have written a handler class for the below trigger senario:

When a Contact (Account is null) is created with rating(a custom field - text type), check for existing Account record with Site(ex: www.emaildomain.com) and rating (as contact's rating), and relate that orphan contact with that account record.

I am getting the attached errors

public class ContactTriggerHandler 
{
    public static void handleAfterInsert(List<Contact> newContacts)
    {
            Map<String, String> contactSiteRatingMap = new Map<String, String>();
                For(Contact newContact: newContacts)
                {
                    if(newContact.AccountId == null && newContact.Site != null && newContact.Rating__c != null)
                    {
                        contactSiteRatingMap.put(newContact.Site, newContact.Rating__c);
                    }
                }
                if(!contactSiteRatingMap.isEmpty())
                {
                List<Account> matchingAccounts = [SELECT Id, Site, Rating__C from Account
                                                WHERE Site IN : contactSiteRatingMap.keySet() AND 
                                                Rating__c IN : contactSiteRatingMap.values()];
                
                List<Contact> contactsToUpdate = new List<Contact>();
                for(Contact newContact : newContacts)
                {
                    if(newContact.AccountId == null && newContact.site != null && newContact.Rating__c != null)
                    {
                        for(Account matchingAccount : matchingAccounts)
                        {
                            if(newContact.Site == matchingAccount.site && newContact.Rating__c == matching.Rating__c)
                            {
                                newContact.AccountId = matchingAccount.Id;
                                contactsToUpdate.add(newContact);
                                break;
                            }
                        }
                    }
                    }
                    if(!contactsToUpdate.isEmpty())
                    {
                        update contactsToUpdate;
                    }
                }
    }
}
User-added image
1- Write a batch class to update leads status as closed lost if no activity has been performed for last 30 days and send notification to manager
I am getting the attached wrrorUser-added image
global class UpdateLeadStatusBatch implements Database.Batchable<sObject> {

    global Database.QueryLocator start(Database.BatchableContext BC) {
        DateTime thirtyDaysAgo = System.now().addDays(-30);
        String query = 'SELECT Id, OwnerId, Owner.ManagerId__c FROM Lead WHERE LastActivityDate <= :thirtyDaysAgo AND Status != \'Closed - Lost\'';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope) {
        List<Lead> leadsToUpdate = new List<Lead>();
        Set<Id> managerIds = new Set<Id>();

        for (sObject s : scope) {
            Lead lead = (Lead) s;
            lead.Status = 'Closed - Lost';
            leadsToUpdate.add(lead);

            // Access the manager's Id through the custom field
            Id managerId = (Id)lead.get('Owner.ManagerId__c');
            if (managerId != null) {
                managerIds.add(managerId);
            }
        }

        update leadsToUpdate;

        // Send Notification to Managers
        // Using Email Services to send email notifications
        if (!managerIds.isEmpty()) {
            List<Messaging.SingleEmailMessage> emailMessages = new List<Messaging.SingleEmailMessage>();

            for (Id managerId : managerIds) {
                // Construct and send email to the manager
                User managerUser = [SELECT Id, Email FROM User WHERE Id = :managerId LIMIT 1];

                if (managerUser != null && !String.isBlank(managerUser.Email)) {
                    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                    email.setSubject('Lead Status Update');
                    email.setHtmlBody('<p>Hello, ' + managerUser.Name + ',</p>' +
                                      '<p>The status of some leads has been updated to "Closed - Lost" due to inactivity.</p>' +
                                      '<p>Thank you!</p>');
                    email.setTargetObjectId(managerUser.Id);
                    email.setSaveAsActivity(false);
                    emailMessages.add(email);
                }
            }

            if (!emailMessages.isEmpty()) {
                List<Messaging.SendEmailResult> sendResults = Messaging.sendEmail(emailMessages);
                for (Messaging.SendEmailResult result : sendResults) {
                    if (!result.isSuccess()) {
                        System.debug('Failed to send email: ' + result.getErrors()[0].getMessage());
                    }
                }
            }
        }
    }

    global void finish(Database.BatchableContext BC) {
        // Any logic you want to execute after the batch finishes
    }
}
 
Develop a trigger that sends an email notification to the account owner when a high-priority case is created or updated.

I have written the below code but email is not getting fired 

public class CaseEmailNotificationHandler {
    public static void sendEmailNotifications(List<Case> casesToUpdate) {
        List<Messaging.SingleEmailMessage> emailMessages = new List<Messaging.SingleEmailMessage>();
 
        // Collect Account Owner Ids for high-priority cases and fetch User information
        Map<Id, User> accountOwners = new Map<Id, User>();
        
        for (Case updatedCase : casesToUpdate) {
            if (updatedCase.Priority == 'High') {
                Id ownerId = updatedCase.Account.OwnerId;
                
                // Check if the ownerId has not been processed already
                if (!accountOwners.containsKey(ownerId)) {
                    List<User> owners = [SELECT Id, Name, Email FROM User WHERE Id = :ownerId LIMIT 1];
                    if (!owners.isEmpty()) {
                        accountOwners.put(ownerId, owners[0]);
                    } else {
                        System.debug('No User found for ownerId: ' + ownerId);
                    }
                }
 
                User accountOwner = accountOwners.get(ownerId);

                if (accountOwner != null && !String.isBlank(accountOwner.Email)) {
                    // Create email message
                    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                    email.setSubject('High-Priority Case Notification');
                    email.setHtmlBody('<p>Hello, ' + accountOwner.Name + ',</p>' +
                                      '<p>A high-priority case has been created or updated. Please review the details.</p>' +
                                      '<p>Case Number: ' + updatedCase.CaseNumber + '</p>' +
                                      '<p>Case Subject: ' + updatedCase.Subject + '</p>' +
                                      '<p>Priority: ' + updatedCase.Priority + '</p>' +
                                      '<p>Thank you!</p>');
                    email.setTargetObjectId(accountOwner.Id);
                    email.setSaveAsActivity(false);
                    emailMessages.add(email);
                } else {
                    System.debug('Email not sent due to missing or invalid recipient for case Id: ' + updatedCase.Id);
                }
            }
        }
         
        if (!emailMessages.isEmpty()) {
            List<Messaging.SendEmailResult> sendResults = Messaging.sendEmail(emailMessages);
            for (Messaging.SendEmailResult result : sendResults) {
                if (!result.isSuccess()) {
                    System.debug('Failed to send email: ' + result.getErrors()[0].getMessage());
                }
            }
        }
    }
}
trigger CaseEmailNotificationTrigger on Case (after insert, after update) {
    if (Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)) {
        CaseEmailNotificationHandler.sendEmailNotifications(Trigger.new);
    }
}
Can you help me wirte a handler class for the below senario

            5. On account record deletion store that record in Backup object.

Create a new object Backup. In that create Long Text field - Record Backup.

Only those fields that have values must be saved in this with their fieldname and fieldvalue, also save Name of user who created this record and with createddate, lastmodified date.Each field value must start on new line.




trigger createBackup on Account (after delete) 
{
 if(trigger.isDelete && trigger.isAfter)
 {
  List<My_Backup__c> lstToInsrt = new List<My_Backup__c>();  
  for(Account deletedAcc : trigger.old)
  {
   system.debug('deletedAcc '+deletedAcc );
   My_Backup__c backup = new My_Backup__c();
   backup.Name = deletedAcc.name;
   lstToInsrt.add(backup);
   system.debug('backup '+backup);
  }
  if(lstToInsrt.size()>0)
  {
   insert lstToInsrt;
   system.debug('list'+lstToInsrt);
  }
 }
}
Can you help me write a handler class for the below code
 

         4. Send email when the Lead Owner changes. Send email to the new lead owner and keep your respective Mentors in Cc of email.

( email body must have proper contain )


public class SendEmailHandler {
    List<Messaging.SingleEmailMessage> mails = 
  new List<Mesaging.SingleEmailMessage>();
    {
  for (Lead mylead : Trigger.new) {
    if (mylead.Email != null && mylead.FirstName != null) {
    
      Messaging.SingleEmailMessage mail = 
      new Messaging.SingleEmailMessage();
    
      
      List<String> sendTo = new List<String>();
      sendTo.add(mylead.Email);
      mail.setToAddresses(sendTo);
    
      // Step 3: Set who the email is sent from
      mail.setReplyTo('abc@gmail.com');
      mail.setSenderDisplayName('Lead has been created');
    
      // (Optional) Set list of people who should be CC'ed
      List<String> ccTo = new List<String>();
      ccTo.add('abc@gmail.com');
      mail.setCcAddresses(ccTo);

      // Step 4. Set email contents - you can use variables!
      mail.setSubject('Lead Owner has been changed');
      String body = 'Dear ' + mylead.FirstName + ', ';
      body += 'The Lead owner has been changed';
      body += 'Please take care of the lead';
      
      mail.setHtmlBody(body);
    
      // Step 5. Add your email to the master list
      mails.add(mail);
    }
  }
  // Step 6: Send all emails in the master list
  Messaging.sendEmail(mails);
}

}
Can you help complete the below code along with trigger
 

  3. Automate approval process on Quote ( created in previous tasks ) using trigger.

Check approval criteria in trigger.



public class ApprovalProcessHandler {
    public static void approval(){
        Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setObjectId('0055j000009sbROAAY');
//If the next step in your approval process is another Apex approval process, you specify exactly one user ID as the next approver. 
//If not, you cannot specify a user ID and this method must be null.
//req.setNextApproverIds(null);
Approval.ProcessResult processResult = Approval.process(req);
//Valid values are: Approved, Rejected, Removed or Pending.
System.assertequals('Draft', + processResult.getInstanceStatus());
    }
    
}
Can you help me with the below code

 

Note - All Trigger must have a handler.

 

1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.

Create GST (percentage) fields on Product.


Note - All Trigger must have a handler.

 

1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.

Create GST (percentage) fields on Product.


Note - All Trigger must have a handler.

 

1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.

Create GST (percentage) fields on Product.


 
HI Everyone,

Can you help me design this page?
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta name="generator" content="Aspose.Words for .NET 23.8.0" />
      <title></title>
      <style type="text/css">body { font-family:'Times New Roman'; font-size:12pt;
  
    
 }p { margin:0pt }
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

li {
  display: inline;
}

 
</style>
   </head>
   <body>
      <div  >

         <p style="margin-top:11.25pt; margin-left:133.05pt; text-align:justify; line-height:34.15pt"><span style="font-family:Calibri; font-size:28pt">The</span><span style="font-family:Calibri; font-size:28pt; letter-spacing:6.45pt"> </span><span style="font-family:Calibri; font-size:28pt">Dental</span><span style="font-family:Calibri; font-size:28pt; letter-spacing:5.1pt"> </span><span style="font-family:Calibri; font-size:28pt">Hygiene</span><span style="font-family:Calibri; font-size:28pt; letter-spacing:7.55pt"> </span><span style="font-family:Calibri; font-size:28pt">Association</span></p>
<img src="img_girl.jpg" alt="Girl in a jacket" width="100" height="40" >

         <p style="margin-top:6.5pt; margin-right:479.05pt; text-indent:0.65pt; line-height:8pt"><span style="font-family:Calibri; font-size:8pt" >The Dental Hygiene</span></p>
<img src="image/your-image.png" width="300"  style="float: right" />
     <p style="margin-top:7.1pt; margin-left:32.1pt; text-align:justify; line-height:15.85pt"><span style="font-family:Calibri; font-size:13pt">Home</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:52.4pt"> </span><span style="font-family:Calibri; font-size:13pt">Adults</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:59.8pt"> </span><span style="font-family:Calibri; font-size:13pt">Kids</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:61.25pt"> </span><span style="font-family:Calibri; font-size:13pt">News</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:60.9pt"> </span><span style="font-family:Calibri; font-size:13pt">FAQ</span><span style="font-family:Calibri; font-size:13pt; letter-spacing:50.85pt"> </span><span style="font-family:Calibri; font-size:13pt">Glossary</span></p>

         <p style="margin-top:15.55pt; margin-left:259.55pt; text-align:justify; line-height:26.85pt"><span style="font-family:Calibri; font-size:22pt">Kids</span></p>

         <p style="margin-top:23.4pt; margin-right:219.3pt; margin-left:13.1pt; text-indent:0.65pt; line-height:12.45pt"><span style="font-family:Calibri; font-size:9pt">Bringing</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.9pt"> </span><span style="font-family:Calibri; font-size:9pt">up</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.95pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">child</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">with</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.05pt"> </span><span style="font-family:Calibri; font-size:9pt">proper</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.5pt"> </span><span style="font-family:Calibri; font-size:9pt">attention</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.5pt"> </span><span style="font-family:Calibri; font-size:9pt">to</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.35pt"> </span><span style="font-family:Calibri; font-size:9pt">their</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">oral</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.05pt"> </span><span style="font-family:Calibri; font-size:9pt">health</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.9pt"> </span><span style="font-family:Calibri; font-size:9pt">a lifelong</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.25pt"> </span><span style="font-family:Calibri; font-size:9pt">investment</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.55pt"> </span><span style="font-family:Calibri; font-size:9pt">in</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1pt"> </span><span style="font-family:Calibri; font-size:9pt">their</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.85pt"> </span><span style="font-family:Calibri; font-size:9pt">health,</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.2pt"> </span><span style="font-family:Calibri; font-size:9pt">which</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.75pt"> </span><span style="font-family:Calibri; font-size:9pt">will</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.05pt"> </span><span style="font-family:Calibri; font-size:9pt">benefit</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.85pt"> </span><span style="font-family:Calibri; font-size:9pt">them</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">greatly for</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.4pt"> </span><span style="font-family:Calibri; font-size:9pt">the</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">rest</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.8pt"> </span><span style="font-family:Calibri; font-size:9pt">of</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">their</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">lives.</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.1pt"> </span><span style="font-family:Calibri; font-size:9pt">Early</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">childhood</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">cavities</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.05pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">a</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.85pt"> </span><span style="font-family:Calibri; font-size:9pt">disease</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3pt"> </span><span style="font-family:Calibri; font-size:9pt">that can</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.5pt"> </span><span style="font-family:Calibri; font-size:9pt">ruin</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.3pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">child’s</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.35pt"> </span><span style="font-family:Calibri; font-size:9pt">teeth,</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.2pt"> </span><span style="font-family:Calibri; font-size:9pt">even</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.85pt"> </span><span style="font-family:Calibri; font-size:9pt">into</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.75pt"> </span><span style="font-family:Calibri; font-size:9pt">adulthood,</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.8pt"> </span><span style="font-family:Calibri; font-size:9pt">but</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.9pt"> </span><span style="font-family:Calibri; font-size:9pt">it</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.4pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.9pt"> </span><span style="font-family:Calibri; font-size:9pt">easily preventable.</span></p>
   

   <p  style="margin-top:2.6pt; margin-right:226.55pt; margin-left:13.1pt; line-height:12.45pt"><span style="font-family:Calibri; font-size:9pt">There</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.95pt"> </span><span style="font-family:Calibri; font-size:9pt">are</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.75pt"> </span><span style="font-family:Calibri; font-size:9pt">a</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.85pt"> </span><span style="font-family:Calibri; font-size:9pt">wide</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.25pt"> </span><span style="font-family:Calibri; font-size:9pt">variety</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.3pt"> </span><span style="font-family:Calibri; font-size:9pt">of</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.6pt"> </span><span style="font-family:Calibri; font-size:9pt">steps</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.95pt"> </span><span style="font-family:Calibri; font-size:9pt">you</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.1pt"> </span><span style="font-family:Calibri; font-size:9pt">can</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.5pt"> </span><span style="font-family:Calibri; font-size:9pt">take</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.4pt"> </span><span style="font-family:Calibri; font-size:9pt">to</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.35pt"> </span><span style="font-family:Calibri; font-size:9pt">teach</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.55pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">child good</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.8pt"> </span><span style="font-family:Calibri; font-size:9pt">dental</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">habits,</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.5pt"> </span><span style="font-family:Calibri; font-size:9pt">and</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.25pt"> </span><span style="font-family:Calibri; font-size:9pt">one</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.7pt"> </span><span style="font-family:Calibri; font-size:9pt">of</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.6pt"> </span><span style="font-family:Calibri; font-size:9pt">the</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">best</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.9pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">leading</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.8pt"> </span><span style="font-family:Calibri; font-size:9pt">by</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.95pt"> </span><span style="font-family:Calibri; font-size:9pt">example. Make</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.3pt"> </span><span style="font-family:Calibri; font-size:9pt">sure</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.4pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">child</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.2pt"> </span><span style="font-family:Calibri; font-size:9pt">knows</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.95pt"> </span><span style="font-family:Calibri; font-size:9pt">how</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.05pt"> </span><span style="font-family:Calibri; font-size:9pt">much</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.75pt"> </span><span style="font-family:Calibri; font-size:9pt">importance</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.25pt"> </span><span style="font-family:Calibri; font-size:9pt">you</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.1pt"> </span><span style="font-family:Calibri; font-size:9pt">place</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.85pt"> </span><span style="font-family:Calibri; font-size:9pt">on dental</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.8pt"> </span><span style="font-family:Calibri; font-size:9pt">health</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">so</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.5pt"> </span><span style="font-family:Calibri; font-size:9pt">they</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.65pt"> </span><span style="font-family:Calibri; font-size:9pt">know</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">that</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.55pt"> </span><span style="font-family:Calibri; font-size:9pt">it</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.05pt"> </span><span style="font-family:Calibri; font-size:9pt">is</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.9pt"> </span><span style="font-family:Calibri; font-size:9pt">something</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:4.5pt"> </span><span style="font-family:Calibri; font-size:9pt">to</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.35pt"> </span><span style="font-family:Calibri; font-size:9pt">be</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.55pt"> </span><span style="font-family:Calibri; font-size:9pt">valued. Brushing</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.95pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"> </span><span style="font-family:Calibri; font-size:9pt">teeth</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.15pt"> </span><span style="font-family:Calibri; font-size:9pt">along</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">with</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.4pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.9pt"> </span><span style="font-family:Calibri; font-size:9pt">child</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.55pt"> </span><span style="font-family:Calibri; font-size:9pt">and</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.25pt"> </span><span style="font-family:Calibri; font-size:9pt">letting</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.85pt"> </span><span style="font-family:Calibri; font-size:9pt">them</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> </span><span style="font-family:Calibri; font-size:9pt">follow your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.9pt"> </span><span style="font-family:Calibri; font-size:9pt">lead</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.4pt"> </span><span style="font-family:Calibri; font-size:9pt">can</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.5pt"> </span><span style="font-family:Calibri; font-size:9pt">be</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.55pt"> </span><span style="font-family:Calibri; font-size:9pt">really</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.75pt"> </span><span style="font-family:Calibri; font-size:9pt">helpful</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.25pt"> </span><span style="font-family:Calibri; font-size:9pt">in</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1pt"> </span><span style="font-family:Calibri; font-size:9pt">setting</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.7pt"> </span><span style="font-family:Calibri; font-size:9pt">up</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:0.95pt"> </span><span style="font-family:Calibri; font-size:9pt">the</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.15pt"> <</span><span style="font-family:Calibri; font-size:9pt">habit</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.05pt"> /span><span style="font-family:Calibri; font-size:9pt">of</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1.6pt"> </span><span style="font-family:Calibri; font-size:9pt">teeth brushing</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3.45pt"> </span><span style="font-family:Calibri; font-size:9pt">in</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:1pt"> </span><span style="font-family:Calibri; font-size:9pt">your</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:2.25pt"></span><span style="font-family:Calibri; font-size:9pt">child’s</span><span style="font-family:Calibri; font-size:9pt; letter-spacing:3pt">  </span></p>
   
      </div>
   </body>
</html>
User-added image
HI Everyone,

I have written the below code :
 
Can you write map instead of a list  . Instead of two for loops pass maps:
 
public class HelperAccount{
    public static void helpaccmethod(List<account> oldAccount, List<account> newAccount){
        List<contact> conList=[select lastname,otherphone,accountid,phone from contact 
                               where accountid IN: newAccount];
        map<id,string> oldAccidVsPhone= new map<id,string>();
        map<id,string> newAccidVsPhone= new map<id,string>();
        for(account newAcc: newAccount){
            for(account oldAcc: oldAccount){
                if(newAcc.phone!=oldAcc.phone && oldAcc.id==newAcc.id){
                    oldAccidVsPhone.put(oldAcc.id,oldAcc.phone);
                    newAccidVsPhone.put(newAcc.id,newAcc.phone);
                }
            }
        }
        list<contact> updateContactList= new List<contact>();
for(contact con: conList){
            if(oldAccidVsPhone.containskey(con.accountid)){
                con.phone=oldAccidVsPhone.get(con.accountid);
                con.Phone=newAccidVsPhone.get(con.accountid);
                updateContactList.add(con);
            }
        }
        if(updateContactList.size()>0){
            update updateContactList;
        }
    }
}
 
Trigger:
 
trigger UpdateAccount on Account (before update,after update) {
    if(trigger.isUpdate && trigger.isBefore){
        HelperAccount.helpaccmethod(trigger.old,trigger.new);
    }
}
Hi Everyone,

I have to write a handler class and a trigger on the below senario

Create two feilds on Contact Ratilg__c and Site__c. NOw once a contact is created or updated the contact should search for the site name of the attacunt which is entered on site__c  of the oncate and associated the account with the contact. Then update the accounts Rating feild  as per the contact Rating__c feild.

Below is the code that I have written

Handl;er class

public class ContactTriggerHandler {
    public static void handleAfterInsert(List<Contact> newContacts) {
        Map<String, String> contactSiteRatingMap = new Map<String, String>();
        for (Contact newContact : newContacts) {
            if(newContact.AccountId == null && newContact.Site__c != null && newContact.Rating__c != null){
                contactSiteRatingMap.put(newContact.Site__c, newContact.Rating__c);
            }
        }
        if (!contactSiteRatingMap.isEmpty()) {
            List<Account> matchingAccounts = [SELECT Id, Site, Rating FROM Account
                                              WHERE Site IN :contactSiteRatingMap.keySet() AND 
                                              Rating IN :contactSiteRatingMap.values()];
            List<Contact> contactsToUpdate = new List<Contact>();
            for (Contact newContact : newContacts) {
                if (newContact.AccountId == null && newContact.Site__c != null && newContact.Rating__c != null) {
                    for (Account matchingAccount : matchingAccounts) {
                        if (newContact.Site__c == matchingAccount.Site && newContact.Rating__c == matchingAccount.Rating) {
                            newContact.AccountId = matchingAccount.Id;
                            contactsToUpdate.add(newContact);     
                        }
                    } 
                }
            }
            if (!contactsToUpdate.isEmpty()) {
                
                update contactsToUpdate;                
            }
        }  
    }  


Trigger
trigger ContactTrigger on Contact(after insert)
{
    ContactTriggerHandler.handleAfterInsert(Trigger.new);
}

 
Hi Everyone,

I have written a handler class for the below trigger senario:

When a Contact (Account is null) is created with rating(a custom field - text type), check for existing Account record with Site(ex: www.emaildomain.com) and rating (as contact's rating), and relate that orphan contact with that account record.

I am getting the attached errors

public class ContactTriggerHandler 
{
    public static void handleAfterInsert(List<Contact> newContacts)
    {
            Map<String, String> contactSiteRatingMap = new Map<String, String>();
                For(Contact newContact: newContacts)
                {
                    if(newContact.AccountId == null && newContact.Site != null && newContact.Rating__c != null)
                    {
                        contactSiteRatingMap.put(newContact.Site, newContact.Rating__c);
                    }
                }
                if(!contactSiteRatingMap.isEmpty())
                {
                List<Account> matchingAccounts = [SELECT Id, Site, Rating__C from Account
                                                WHERE Site IN : contactSiteRatingMap.keySet() AND 
                                                Rating__c IN : contactSiteRatingMap.values()];
                
                List<Contact> contactsToUpdate = new List<Contact>();
                for(Contact newContact : newContacts)
                {
                    if(newContact.AccountId == null && newContact.site != null && newContact.Rating__c != null)
                    {
                        for(Account matchingAccount : matchingAccounts)
                        {
                            if(newContact.Site == matchingAccount.site && newContact.Rating__c == matching.Rating__c)
                            {
                                newContact.AccountId = matchingAccount.Id;
                                contactsToUpdate.add(newContact);
                                break;
                            }
                        }
                    }
                    }
                    if(!contactsToUpdate.isEmpty())
                    {
                        update contactsToUpdate;
                    }
                }
    }
}
User-added image
HI Everyone,

Can you help me write a handler class and a trigger for the below senario:
When a Contact (Account is null) is created with rating(a custom field - text type), check for existing Account record with Site(ex: www.emaildomain.com) and rating (as contact's rating), and relate that orphan contact with that account record.