0

i have a custom setting and want to show a record from vf page that when click on that link it will direct redirect on the record rather than go from the setup. Here i have tried 'vf page

    <apex:page showHeader="true" sidebar="true" Controller="InwiseDetailController">
  <apex:form>
    <apex:pageBlock title="InwiseDetail">
       <apex:pageBlockSection columns="3">
            <apex:pageBlockSectionItem >
                  <apex:outputPanel>
                      <apex:outputLink value="{!customrecords.id}" > view object </apex:outputLink> 
                  </apex:outputPanel>
            </apex:pageBlockSectionItem>

and here is my controller

    public with sharing class InwiseDetailController {
  public Settings__c customrecords{get;set;}

  public Settings__c customrecords(){
    Settings__c s = [select id,name from Settings__c where name = 'default'];
    return s;
  }

}

but when i click on the link it didn;t redirect me on the page. how can i? please help me

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Adrian Larson
    Oct 17, 2017 at 14:33

1 Answer 1

1

As pointed out in comments, 1. The issue is with your class. You have a method in place which is not called from anywhere neither it is a getter method, and so it does not instantiates it with the custom setting record. 2. When using custom setting, avoid SOQL. We do have methods in place to get records.

Class:

public setting__c getCustomrecords(){

    setting__c s = setting__c.getValues('Default');
    return s;
}

VF page:

<apex:page showHeader="true" sidebar="true" Controller="InwiseDetailController">
    <apex:form>
        <apex:pageBlock title="InwiseDetail">
            <apex:pageBlockSection columns="3">
                <apex:pageBlockSectionItem>
                    <apex:outputPanel>
                        <apex:outputLink value="/{!customrecords.id}"> view object </apex:outputLink>
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
1
  • This page is working fine in classic but not in lightning...can you please help me to solve this?
    – SFDC_USER
    Nov 8, 2017 at 8:08

Not the answer you're looking for? Browse other questions tagged .