Objective: To display the URL of VF page as a link on the record detail page and when clicked on that, the VF page should open in a separate tab by taking the record values, such as name dynamically.
What I have achieved till now:
VF Page:
<apex:page standardController="Project__c" extensions="myExtension">
<apex:form >
<html>
Name of the record: {!currentRecord.Name}
</html>
</apex:form>
</apex:page>
Controller:
public class myExtension {
public project__c currentRecord{get; set;}
public myExtension(ApexPages.StandardController controller) {
currentRecord = [SELECT Id, Name FROM project__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
}
}
And I have created a formula field that displays the URL of this VF page on the record detail page. It is as follows:
HYPERLINK("/apex/Project?recid="&CASESAFEID(Id) , "View Chart", "_blank")
But, when I click on the URL, I am getting the following error:
List has no rows for assignment to SObject An unexpected error has occurred. Your development organization has been notified.
Can anyone please let me know how to achieve this scenario? Thank you advance