I have a method in ConnectedApiHelper class :

public static ConnectApi.BatchResult[] Gaurav2(String communityId, String subjectId,  ArrayList<String> textWithMentions) {
        //ConnectApi.BatchResult[] result = new ConnectApi.BatchResult[];
        List<ConnectApi.BatchInput> batchInputs = new List<ConnectApi.BatchInput>{};

        return  (new ConnectApi.BatchResult[]()) ;


and I am calling it from developer console :

List<String> arr =  new List<String>();
arr.add('Hey {00536000002DqEu} , Gaurav1?');
arr.add('Hey {00536000002DqEu} , Gaurav2?');

ConnectApi.BatchResult[] rs =   ConnectApiHelper.Gaurav2('0DB36000000TNuDGAW','me',arr);

But its giving me error :

enter image description here

  • 1
    check return type its ConnectApi.BatchResult[] for Gaurav2 method. – Nachiket Deshpande Feb 20 '17 at 10:48

You function returns a ConnectApi.BatchResult[] variable.

And you're trying to get a String variable as result.

Just replace:

ConnectApi.BatchResult[] rs = ConnectApiHelper.Gaurav2('0DB36000000TNuDGAW','me',arr);


Here's a great tutorial to learn basic Apex. If you think you need it.

ps:dedicace to @RahulSharma :D

  • Maybe it would be also helpful for others if you can add link to documentation :) – Raul Feb 20 '17 at 10:51
  • 1
    A documentation link for: "How to get a variable as a result of a function"? :D – Martin Lezer Feb 20 '17 at 10:54
  • Yeah, sound silly, but then we still have a question asked here :D – Raul Feb 20 '17 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.