TriggerCreate an insert trigger on Lead, which will update rating as...

Create an insert trigger on Lead, which will update rating as hot, whenever new Lead record is created.

To the above task create and trigger on Lead Object, and paste the below code to see results.

trigger Leadtrigger on Lead (before insert) {
    if(Trigger.isBefore && Trigger.isInsert){
        for(Lead eachLead: Trigger.New){
            eachLead.Rating = 'Hot';
        }
    }
}

If you have already trigger on Lead, use below code.

if(Trigger.isBefore && Trigger.isInsert){
        for(Lead eachLead: Trigger.New){
            eachLead.Rating = 'Hot';
        }
    }

- Advertisement -spot_img

More From UrbanEdge

Top Salesforce Static Code Analysis Tools: Enhancing Code Quality and Security

#Heading1Introduction2What is Salesforce?3The Importance of Code Analysis4Understanding Static Code...

Trigger Challenge #12: Understanding the Trigger on Account and its Impact on Salesforce Development

As a Salesforce developer, understanding how triggers work is...

Best Practices for Apex Triggers

Introduction Apex Triggers are a fundamental aspect of Salesforce development,...

Why LWC was introduced?

Salesforce LWC: The Best Way to Create Customized User...
- Advertisement -spot_img