Skip to main content

I wrote below logic in Leadhelper class

public static void integrationuserleadsourceValidation(List<Lead> newLeadss, Map<Id, Lead> oldLeadMap) {

        // Iterate through the new leads

        for (Lead leadRecord : newLeadss) {

            // Check if the lead is created by an integration user

            if (leadRecord.CreatedById != null && leadRecord.CreatedBy.Profile.Name == 'Integration Users'){

     if (leadRecord.LeadSource != oldLeadMap.get(leadRecord.Id).LeadSource) {

                        leadRecord.addError('Lead Source cannot be changed for leads created by integration users with a specified field.');

     }}}}

but when we call this method so getting  error Method does not exist or incorrect signature void integrationuserleadsourceValidation(List) from the type Leadhelper

2 Antworten
  1. 12. Jan. 2024, 11:54

    Hi @Rashmee Kasawar

     

    Method does not exist or incorrect signature, typically happens when there's a mismatch between the method's signature in the class where it's defined and how it's being called in another class 

     

    you can check the below sytnax:

    trigger LeadTrigger on Lead (before update) {

    // Only call the helper method for before update events

    if (Trigger.isBefore && Trigger.isUpdate) {

    // Pass both Trigger.new and Trigger.oldMap to the helper method

    Leadhelper.integrationuserleadsourceValidation(Trigger.new, Trigger.oldMap);

    }

    }