You need to sign in to do that
Don't have an account?
Richard Estigoy
Getting the ID from the url of Apex Pages
Hi. Can you please guide me and help me regarding on the fetching of ID from the URL?
Here is the sample link: https://test.dev.cs7.my.salesforce.com/a0cM00000043ST4
I want to get the ID from the URL using my controller for me to be able to use the ID for Query purposes.
public List<MyCustomObject> getacts(){
List<MyCustomObject> acts = [SELECT Id, a,
b,
c
FROM MyTable where Id ='a0cM00000043ST4'];
return acts;
}
Can you help me please. Thank you.
Here is the sample link: https://test.dev.cs7.my.salesforce.com/a0cM00000043ST4
I want to get the ID from the URL using my controller for me to be able to use the ID for Query purposes.
public List<MyCustomObject> getacts(){
List<MyCustomObject> acts = [SELECT Id, a,
b,
c
FROM MyTable where Id ='a0cM00000043ST4'];
return acts;
}
Can you help me please. Thank you.
In order to retrieve a records id from the URL Parameters on a visualforce page via apex. All it takes its
String recId = ApexPages.currentPage().getParameters().get('id');
Hope this helps.
Thanks for your reply.
I've tried the solution that you gave me, still not working.
I have an export button in my standard page. I have 1-master object and 2 child objects. For me to be able to map the child object I need to get the ID from the URL. Do you have any suggesttions for this?
Controller:
private final List<MyObject> acts;
public ContructorName(){
String recId = ApexPages.currentPage().getParameters().get('id');
acts = [SELECT Id, column1
FROM Mytable
where Id = :recId];
}
public List<MyObject> getacts(){
return acts;
}
VisualForcePage:
<apex:dataTable value="{!acts}" var="test" cellpadding="1" cellspacing="1" border="1" width="100%" align="center">
<apex:column >
<apex:facet name="header"><b style="color: #00645c">column1</b></apex:facet>
<apex:outputText value="{!test.column1}"/>
</apex:column>
</apex:dataTable>
Thanks.