0

I want to send data to function i guess its want to List type but i couldnt change well in my method rather am not sure yet

this is my error code: Method does not exist or incorrect signature: void UpdateContactOwner(List) from the type anon

List<Account> acc = new List<Account>();
acc = [SELECT OwnerId,Name From Account where Cari_Grup_Kodu__c IN('CO') Limit 1];

integer i = 0;

    if(acc.size() > 0)
    {
        List <String> Names = new List <String>();
        List<String> OwnerIds = new List <String>();
        for (Account acc_i : acc)
        {
            Names.add(acc_i.Name);
            OwnerIds.add(acc_i.OwnerId);
          --->  UpdateContactOwner(Names[i]);
            i = i + 1;
        }

    }

And Here Method

public class EditRecordContacts {

public static string UpdateContactOwner(List<string> names)
{
    List<Contact> contacts = new List<Contact>();
    contacts = [Select Contact.OwnerId From Contact Where Name= :names];
    string a = 'Yes';
    return a; 
}


}

1 Answer 1

0

UpdateContactOwner(List<string> names) accepts List<String> you are trying to provide just String in the form of Names[i].

Move your code outside for loop and pass it just Names list, and that should do.

if(acc.size() > 0)
    {
        List <String> Names = new List <String>();
        List<String> OwnerIds = new List <String>();
        for (Account acc_i : acc)
        {
            Names.add(acc_i.Name);
            OwnerIds.add(acc_i.OwnerId);

            i = i + 1;
        }
        EditRecordContacts.UpdateContactOwner(Names);

    }`
4
  • firstly thanks but i try that already i took again same error :( Commented Jul 18, 2019 at 11:26
  • Updated snippet Commented Jul 18, 2019 at 11:27
  • 1
    There is also error in class EditRecordContacts. Should be contacts = [Select Contact.OwnerId From Contact Where Name IN :names];. Not = but IN. @FurkanKuyular Commented Jul 18, 2019 at 11:28
  • Everybody thanks i found my problem i wrote this EditRecordContacts.UpdateContactOwner(Names[i]); in loop again because i want to send Names and OwnerID regular because i have 10 thousand records to change ownerName's Commented Jul 18, 2019 at 11:42

You must log in to answer this question.

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