function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
YukinonYukinon 

Fetch record Id in url not working

Hello any idea why it's not fetching the record id even though I'm using
ApexPages.CurrentPage().getparameters().get('id');

User-added imageI'm not getting any record.

Controller:
public class ActiveOpportunityLineItems {
    private final List<OpportunityLineItem> lineItems;
    public String oppId {get;set;}
    public ActiveOpportunityLineItems(){
       oppId  = ApexPages.CurrentPage().getparameters().get('id');
       lineItems = [SELECT ProductCode,UnitPrice,Description,Status__c From OpportunityLineItem WHERE Status__c = 'ACTIVE' AND OpportunityId = :oppId];
    }
    
    public List<OpportunityLineItem> getActiveOpportunityLineItems(){
        return lineItems;
    }
    
}

Component:
<apex:component controller="ActiveOpportunityLineItems" access="global">
	<apex:dataTable border="below" value="{!ActiveOpportunityLineItems}" var="active_opp" width="75%" style="text-align:center;" >
        <apex:column value="{!active_opp.ProductCode}" headerValue="Product Code" />
	    <apex:column value="{!active_opp.Description}" headerValue="Line Description"/>
         <apex:column value="{!active_opp.UnitPrice}" headerValue="Sales Price"/>
         <apex:column value="{!active_opp.Status__c}" headerValue="Status"/>
	</apex:dataTable>
</apex:component>

Thanks!
mukesh guptamukesh gupta
Hi Yukinon,

It should be work, First you need to add below code for debug 
 
System.debug("OppId--->> "+ApexPages.currentPage().getParameters().get('id'));

After that we will make sure what is exact issue

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh