1

I'd be glad if someone could help. I'm trying to retrieve Book object records from a Booking request object page via an availability link on the Booking request VF page where Book and Booking request are related by a 1:M lookup relationship.

I'm having this error,

"Method does not exist or incorrect signature: void currentPages() from the type ApexPages"

The Request VF page:

<apex:page standardController="Booking_request__c">
    <apex:form >
      <apex:pageblock tabStyle="Booking_request__c" >
        <apex:outputLabel for="startDt">Start Date and Time</apex:outputLabel>
        <apex:inputField value="{! Booking_request__c.Start_time__c }"/>
        <apex:outputLabel for="startDt">End Date and Time</apex:outputLabel>
        <apex:inputField value="{! Booking_request__c.End_time__c }"/>
        <apex:outputLabel for="startDt">Book type</apex:outputLabel>
        <apex:inputField value="{! Booking_request__c.Book_Type__c }"/>

        <apex:outputLink value="/apex/displaybookrecord?id{bk.id}"> Check Availability </apex:outputLink>

        </apex:pageblock>
    </apex:form>
</apex:page>

VF page to display Book records upon clicking on the Check availability link

<apex:page controller="mycontroller" tabstyle="Book__c">
<apex:form >
<apex:tabPanel >
<apex:tab label="Details">
<apex:detail title="true" relatedlist="false"/>
</apex:tab>
</apex:tabPanel>
</apex:form>
</apex:page>

APEX code with SOQL to rretrieve the book records

public class mycontroller
public List<Book__c> book  {get;set;} 
public mycontroller () 
{ Id id = apexpages.currentPage().getParameters().get('ID');
book = [SELECT Name FROM  Book__c where Id=:id]; }
0

First of all, pass the id value properly like this (you have missed =):

<apex:outputLink value="/apex/displaybookrecord?id={bk.id}"> Check Availability </apex:outputLink>

Secondly, Change this line Id id = apexpages.currentPage().getParameters().get('ID');

to this:

String strId = ApexPages.currentPage().getParameters().get('id');

Use this strId in SOQL query.

Also, Id is a data type, so do not use a variable name as id which could be confusing.

| improve this answer | |
0

Parameters are always returned in String data type so if you want one as an Id data type for use in a query you can do this:

Id recordId = ( Id )ApexPages.currentPage().getParameters().get( 'id' );

Keep in mind that parameters are key->value pairs so you need to keep the case when you're getting the parameters. Also be sure that you're formatting the URL in your links like Santanu Boral response as you were missing the "=" sign. Again, that is necessary as they are key->value pairs in the parameters as with any other query string.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.