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
fiona gentryfiona gentry 

Anonymous apex unable to execute static method of class

Hi Folks,

I have a apex class which i am trying to execute via Developer console Anonymous apex
ERTT_TaskCreationValidation.isAccountResearchcompleted('01236000000OnsMAAS','01236000000OnsKAAS');

but getting the error as
Line: 1, Column: 28
Method does not exist or incorrect signature: void isAccountResearchcompleted(String, String) from the type ERTT_TaskCreationValidation


Here is Apex class for reference
 
public class ERTT_TaskCreationValidation {
    public static void isAccountResearchcompleted(List<Task> ERTTTasks,Set<Id> caseIdset)
    {
        map<id, Task> mapTaskDetails ;
		map<Id, Case> mapCaseWithTaskList = new  map<Id, Case>([select id, (Select id, Action__c from Tasks )  from Case where Id in: caseIdset]); 
        for(Task t : ERTTasks)
        {
            Boolean validationFlag = true;
            for(Task t1:  mapCaseWithTaskList.get(t.WhatId).tasks)
            {
                if(t1.Action__c == 'Airtel Account Research')
                {
                    validationFlag = false;
                }
            }
            if(validationFlag)
            {
                t.addError('Please Create a task for Airtel Account Research before creating any other Task');
            }
            
        }
    }
}

Your response in appreciated

Regards
Fiona
 
Best Answer chosen by fiona gentry
Antoninus AugustusAntoninus Augustus
Hi Fiona,

As Ankaiah mentioned, you're passing incorrect values to your method. Here's how it should look like:
List<Task> lstTasks = [SELECT ID FROM Task WHERE ID = '01236000000OnsMAAS'];
Set<Id> caseIds = new Set<Id>{'01236000000OnsKAAS'};

ERTT_TaskCreationValidation.isAccountResearchcompleted(lstTasks, caseIds);

Your method takes a list of Tasks as the first arguement and a set of Case Ids as the second.

All Answers

AnkaiahAnkaiah (Salesforce Developers) 
Hi Fiona,

Your static method have list & Id parameters but you were passing strings for the both parameters.

You need to pass the List of tasks & case ids to the static method.

If this helps, Please mark it as best answer.

Thanks!!
 
fiona gentryfiona gentry
Hu Ankaiah,

Can you share me a sample how it should look like with sample  List of tasks & case ids to the static method.

Thank you
Fiona
Antoninus AugustusAntoninus Augustus
Hi Fiona,

As Ankaiah mentioned, you're passing incorrect values to your method. Here's how it should look like:
List<Task> lstTasks = [SELECT ID FROM Task WHERE ID = '01236000000OnsMAAS'];
Set<Id> caseIds = new Set<Id>{'01236000000OnsKAAS'};

ERTT_TaskCreationValidation.isAccountResearchcompleted(lstTasks, caseIds);

Your method takes a list of Tasks as the first arguement and a set of Case Ids as the second.
This was selected as the best answer