First I am working in Ligntning. I have created a VF page on a Custom object (Fact Finder) which is a child of Opportunity. This VF page opens another VF page based on another Custom object which is a child of Fact Finder (Driver). The commandButton on the first VF page has an action {!addDriver}. The controller is as follow:

 public PageReference addDriver()
    insert (This.FF);
    PageReference ref = new Pagereference('/apex/FFDriver');
    ref.getParameters().put('FFId', FF.Id);
    return ref;

The second VF page opens fine and passed the Fact Finder id. On this second page I have 2 Commandbutton {!save} and {!cancel} when selected I want the first VF page to be loaded again. When I use

public PageReference cancel(){    

   PageReference page = new PageReference('/apex/MotorForm');   
   page.setRedirect (true);
   return page;       

I have the error message

List has no rows for assignment to SObject

When I add the id:

PageReference page = new PageReference('/apex/MotorForm' + FFId); 

I get this error message

Page MotorForma0OO0000007SEKBMA4 does not exist

What am I missing? Is it linked to Lightning?


Constructor for the 1st VF page:

public with sharing class FFFormCtrExt {


 public Fact_Finder__c FF {get; set;}
 public Opportunity opp {get;set;}
 string recordId = ApexPages.currentPage().getParameters().get('recordId');
 public List<FFDriver__c>driv = new List<FFDriver__c>();

 public FFFormCtrExt(ApexPages.StandardController controller) {

 opp =  [SELECT Id, Name, ABN__c, ACN__c, Email__c, Phone__c, Address__c, Primary_Contact__c, Account.Name FROM Opportunity WHERE Id =:ApexPages.currentPage().getParameters().get('recordId')];

 FF.Opportunity_Name__c= recordId

Constructor for 2nd VF Page:

    public with sharing class FFDriverFormCtrExt {

 public FFDriver__c FFD  {get; set;}
 public Fact_Finder__c FF {get;set;}
 String FFId = ApexPages.currentPage().getParameters().get('FFId');

 public FFDriverFormCtrExt (ApexPages.StandardController controller){

 FF = [SELECT Id, Name FROM Fact_Finder__c WHERE Id =:ApexPages.currentPage().getParameters().get('FFId')];

 FFD.Motor_Fact_Finder_No__c = FFId;

enter image description here Thank you for your help. Sylvie

  • How is this going to be used in lightning by the way?
    – martin
    Aug 8, 2016 at 23:19
  • I have created a Lightning Component with 7 buttons on the Opportunity detail page that open each a different VF page. The motor page is special because it opens another sub VF page. For the 7 main pages I already have only one Controller. (see picture above)
    – ultima67
    Aug 8, 2016 at 23:42
  • Still, it would probably be good to have the motor page and the sub page using the same controller. Also, you can get rid of the @AuraEnabled parts in the controller since that annotation is only used for the server side controller methods in lightning components. Even though you've got these links here in lightning, the pages themselves are straight visualforce.
    – martin
    Aug 9, 2016 at 1:17

1 Answer 1


The problem is that your id is getting mashed together with the page name, and that the FFId parameter is required for the second page while the first page needs an recordId parameter with an Opportunity Id value.

The error message you are getting comes from this line in your constructor:

opp =  [SELECT Id, Name, ABN__c, ACN__c, Email__c, Phone__c, Address__c, Primary_Contact__c, Account.Name FROM Opportunity WHERE Id =:ApexPages.currentPage().getParameters().get('recordId')];

since there are no opportunities being returned from the query. You should add ?recordId= to the page reference when navigating to the first page and make sure that it is being set equal to an opportunity id.

It's also worth mentioning that you can use the same controller for both pages and navigate between the pages similarly to this

  • Hi Martin, thank you for your response. Still getting the error 'List has no rows for assignment to SObject '
    – ultima67
    Aug 8, 2016 at 5:12
  • You need to check the debug logs for which line this error is seen. Then, It would be easier the resolve this issue.
    – Devendra
    Aug 8, 2016 at 5:53
  • I can't solve that issue with what you have posted here. somewhere in your code, there's a soql query that gets assigned to a single variable and that query is coming back empty.
    – martin
    Aug 8, 2016 at 5:53
  • What does the constructor look like for the controller for your "MotorForm" page?
    – martin
    Aug 8, 2016 at 6:22
  • I have updated my post with the 2 constructors.
    – ultima67
    Aug 8, 2016 at 22:40

You must log in to answer this question.

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