You need to sign in to do that
Don't have an account?
Override New button on Contact?Works sometimes ?? WHy Please Help??
This error comes up sometimes, and sometimes it does not... When I refresh the screen, it worked, ... Can someone tell me how to fix my code so that it works all the time...
I am overriding the New Contact button on the Account side...
so from Account click new contact and this is the code pointing to it:
System.QueryException: List has no rows for assignment to SObject????
Class.OverrideNewContactExtension.<init>: line 10, column 17
External entry point
public class OverrideNewContactbutton {
Account a{get;set;}
boolean gotaccount=false;
public OverrideNewContactbutton(ApexPages.StandardController stdController){
string ret=ApexPages.currentPage().getParameters().get('RetURL');
ret=ret.substring(1,ret.length());
if(ret.startswith('001')){
a = [Select name,recordtype.name,id
from Account where id=:ret];
gotaccount=true;
}
}
public PageReference init() {
String redirectUrl = '';
String recordTypeId = System.currentPageReference().getParameters().get('RecordType');
Id parterProfileId = [SELECT Id FROM Profile WHERE Name ='donation User'].Id;
if (UserInfo.getProfileId() == parterProfileId) {
return null;
}
else {
if(gotaccount) {
redirectUrl = '/003/e?accid='+a.id+'&RecordType='+recordtypeId+'&nooverride=1';
}
else {
redirectUrl = '/003/e?nooverride=1';
}
}
PageReference newContact = new PageReference(redirectUrl);
return newContact;
}
public PageReference wizard() {
PageReference Wizard = new PageReference('/apex/testpage');
return Wizard;
}
i guess you are not getting any Id value matching to that of ret ...
try this....
a = [select fields from account where id := stdcontroller.getId()];
All Answers
this is probably because you are getting an empty list in you query
But how come when I am on the Account itself and then I hit New Contact??
Shouldn't that query always not be empty??
Is there another way to do it?
i guess you are not getting any Id value matching to that of ret ...
try this....
a = [select fields from account where id := stdcontroller.getId()];