function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chandraprasanth Gchandraprasanth G 

On lead object If rating is hot then phone number is mandatory.

Harshit Kumar 27Harshit Kumar 27
Hi Shaikh Rayyan,

Please find below the solution to your problem using Handler Class -> 

//LeadTrigger
------------------
trigger LeadTrigger on Lead (before insert){
    if(Trigger.isBefore){
        if(Trigger.isInsert){
            LeadTriggerHandler.main(Trigger.new);
        }
    }
}

//LeadTriggerHandler
----------------------------
public class LeadTriggerHandler{
    public static void main(List<Lead> leadList){
        for(Lead lead : leadList){
            if(lead.Rating == 'Hot' && lead.Phone == NULL){
                lead.Phone.addError('Phone number is mandatory');
            }
        }
    }
}

If this solves your problem then please mark this as the best answer.

Thanks and Regards
Harshit Kumar
Harshit Kumar 27Harshit Kumar 27
Hello chandraprasanth G,
By mistake I wrote someone elses name in the above reply..
mukesh guptamukesh gupta
HI Chandra,

You should use validation rule Instead of trigger , Please follow below validation rule:-

User-added image

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
AnkaiahAnkaiah (Salesforce Developers) 
Hi chandraprasanth,

try with below rule.
AND(ISPICKVAL(Rating,'Hot'), ISBLANK(Phone))

If this helps, Please mark it as best answer.

Thanks!!​​​​​​​
transe divain 9transe divain 9
The USPS Customer Satisfaction Survey allows every USPS guest to share all about their visit experience. https postalexperience com pos
The TechieThe Techie
refer for guidance - https://www.youtube.com/watch?v=5ESRYbA9tWE
 
The TechieThe Techie
Hi,

Refer the following for idea-
https://www.youtube.com/watch?v=4kQ_CAFALos
syed jabeenasyed jabeena
Hi,Chandraprasanth G

AND( ISPICKVAL (Rating,"Hot"),
OR(ISBLANK(Phone__c)

If this helps, Please mark it as best answer.

Thanks Regards,
Syed Jabeena
Arun Kumar 1141Arun Kumar 1141

Hi, Chandraprasanth G

Please follow below validation rule:-

AND( ISPICKVAL(Rating, "Hot") , ISBLANK(Phone))