+ Start a Discussion
Anil DuttAnil Dutt 

Id value is not valid for the Flight_Request__c standard controller

Hi,

I have created a Visual Force page with following extension class

public class FlighRequestPage {
  Flight_Request__c fr;
  Opportunity opp;
  public FlighRequestPage(ApexPages.StandardController stdController)
    {
      fr = (Flight_Request__c)stdController.getRecord();
      opp = [SELECT id , Departure_Date__c   FROM Opportunity WHERE Id = :fr.Opportunity__c];
    if (fr.Outbound_del__c == null)
      {
        fr.Outbound_del__c = opp.Departure_Date__c;
      }
    }
    
    public PageReference Save()
    {
        try
        {
        insert fr;
        }
        catch(DmlException ex)
        {
            ApexPages.addMessages(ex);  
        }
        PageReference pr = new PageReference('/'+  fr.Opportunity__c);
        pr.setRedirect(true);
        return pr;
    }
}

but getting following error

Id value 006d0000005nU0D is not valid for the Flight_Request__c standard controller

Any help would we apprediated

Thanks

Damien_Damien_

The Id you are passing as a parameter into the page isn't of type Flight_Request__c

Anil DuttAnil Dutt

Hi Damien,

 i created a custom list button for Flight_Request__c object and want to show a Visual Force page on button click, Flight_Request__c  is a related list in Opportunity, the opp id passed in the url automatically , i didn't add it and custom button is "List Button" set to "Display in existing window with sidebar"

Damien_Damien_

I'm guessing that using the list button, you either 

a) don't have access to the Id of the specific item on the related list

b) If you do have access, then you are probably grabbing the opp id instead.

 

Put 006d0000005nU0D at the end of the .com/ part of the URL.  Does it take you to a flight_Request__c object?  If not then it is sending the wrong Id in somehow.