I have a JS button, which is calling a web service class method and doing some process. I am trying to convert that to call a VF page and make it lightning compatible. But I am stuck on an error while calling the web service method in the pageref. Pls suggest

global class AddUserToNewTeam{
    public Opportunity objOpp;
    global AddUserToTeam(ApexPages.StandardController stdcontroller) {
        objOpp = (Opportunity)stdController.getRecord();
    public pagereference addTeam(){

     addTeamMember(objOpp.Id); ****ERROR HERE: Error: Compile Error: Method does not exist or incorrect signature: void addTeamMember(Id) from the type  AddUserToNewTeam****

      return new pagereference(url.getsalesforcebaseurl().toexternalform()+'/'+objOpp.Id);
 webservice static boolean addTeamMember(List<Id> opptyIds)
    //all logic

1 Answer 1


You're passing a single Id objOpp.Id, but your method expects a List<Id>

addTeamMember(List<Id> opptyIds)

So, you can create a list and pass that to the method

public pagereference addTeam(){
  List<Id> opportunityIds = new List<Id>();

Or, depending on whether this is the only use case for this method - update the method to accept a single Id and keep the other parts of your code

addTeamMember(Id opptyId)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .