You need to sign in to do that
Don't have an account?
Alex Valavanis 13
apex class assistance
Could you please tell me where the error is here? Is it because there is a blank space somewhere?
The error i am receiving is "Error: Compile Error: Invalid constructor name: MyPageExtension at line 1 column 93"
The error i am receiving is "Error: Compile Error: Invalid constructor name: MyPageExtension at line 1 column 93"
public with sharing class OwnerChangeExtension{public List<Contact>contacts{get;set;}public MyPageExtension (ApexPages.StandardSetController controller){controller.addFields(new List<String>{'Name','FirstName', 'AccountId', 'Account.Name', 'OwnerId','Account.Owner.Name'}); contacts=(List<Contact>)controller.getSelected(); } public PageReference save() { try{ Map<Id, Account> accountById= new Map<Id, Account>(); for(Contact con : contacts){ if(con.AccountId!=null){ if(!accountById.containsKey(con.AccountId)){ Account acc = new Account(Id=con.AccountId, OwnerId=con.Account.OwnerId, Name=con.Account.Name); accountById.put(con.AccountId, acc); } } } update contacts; update accountById.values(); return new ApexPages.Action('{!List}').invoke(); }catch(Exception e){ ApexPages.addMessage(newApexPages.Message(ApexPages.Severity.Error, 'Error occured while updating below records.'+ e.getMessage())); return null; } } public PageReference cancel() { return new ApexPages.Action('{!List}').invoke(); } }
Was my solution helped?