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
Nate Reed 3Nate Reed 3 

Error: Compile Error: Method does not exist or incorrect signature

Hi, Apex noob here. I'm trying to create a trigger that calls the method logTransaction in my "Blockchain" class. It's failing with the message "Error: Compile Error: Method does not exist or incorrect signature: Blockchain.logTransaction(String, String, String, String) at line 3 column 21
 
trigger OpportunityInsertTrigger on Opportunity (before insert) {
    System.debug('Triggered on insert of opportunity. Updating blockchain...');
    String result = Blockchain.logTransaction('123456789', 'DNB', 'Salesforce', 'Opportunity');
}

The method signatures do seem to match. I've tried implementing this as both an instance method and static method and I get the same message when I try to invoke either.

My class:
public class Blockchain {

    public static String logTransaction(String duns, String fromEntity, String toEntity, String state) {
		Map<String,String> arguments = new Map<String,String>();
	    arguments.put('from', fromEntity);
        arguments.put('to', toEntity);
        arguments.put('duns', duns);
        arguments.put('state', state);
        return makeRequest(arguments);
    }
    
    public static String makeRequest(Map<String,String> arguments) {
        Payload payload = new Payload();
		payload.argumentMap = arguments;        
				        
        String url = '';
        Httprequest request = new HttpRequest();
        request.setMethod('POST');
        request.setEndpoint(url);
        request.setBody(payload.toJSONString());
 
        Http http = new Http();
        HttpResponse response = http.send(request);
        
        System.debug('Response status code: ' + response.getStatusCode());
        System.debug('Response: ' + response.getBody());        
        
        return 'OK';
    }

}

 
Best Answer chosen by Nate Reed 3
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri

only @future methods can be accesses in the triggers.

please add@future annotation to your method in Blockchain class

All Answers

Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri

only @future methods can be accesses in the triggers.

please add@future annotation to your method in Blockchain class

This was selected as the best answer
Nate Reed 3Nate Reed 3
Thank you, that fixes it! 
 
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri

please mark my answer as best answer

Thanks