2

I was created a home page component and its type is link. Also created a custom link . I want to access one of the field of custom setting in my custom link is it possible..? My custom link Behavior is "Execute Javascript" or Content Source is "onClick JavaScript".

1

See the Accessing Custom Settings

Formula Fields:

Formula fields only work for hierarchy custom settings; they can’t be used for list custom settings.

{!$Setup.CustomSettingName__c.CustomFieldName__c}

Below code works only when, you are using hierarchy custom settings.

{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 
var customSetInstance = '{!$Setup.lightening16__TestHSetting__c.lightening16__TestName__c}';
alert('::'+customSetInstance);
6
  • When i save my custom link after adding your code getting error : An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Error ID: 1954184272-437363 (-1712020808) – Piyush Kumar Aug 3 '16 at 12:44
  • Hello Dev, my custom setting is list type. – Piyush Kumar Aug 3 '16 at 12:45
  • You are getting an error because list type custom setting is not supported there. – Devendra Aug 3 '16 at 12:58
  • Is there any way to get list type custom setting value in custom link – Piyush Kumar Aug 3 '16 at 13:11
  • One way could be call apex method from there and retrieve a Custom Setting Value. I haven't tried this. Need to try. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… – Devendra Aug 3 '16 at 13:22
1

There is a similar question, here in this post is the answer to retrieve a hierarchy custom setting data: How to Access a Hierarchy Custom Setting from Lightning Component.

Working with list custom setting should be the same.

Basically you have to call the controller and return that custom setting info, then you can save that info to an aura attribute to use it later.


UPDATE: Using custom setting data in visualforce components.

Component or visualforce page:

<apex:page controller="testCont">
    <div>
        {!HiearchySettings.Any_Info__c}
    </div>
    <div>
        {!ListSettings1.Any_Info__c}
    </div>
    <apex:repeat value="{!ListSettings2}" var="settings">
        <p>{!settings.Any_Info__c}</p>
    </apex:repeat>
</apex:page>

Controller side:

public class testCont {
    public MyHiearchy__c getHiearchySettings(){
        return MyHiearchy__c.getInstance();
    }

    public MyList__c getListSettings1(){
        return MyList__c.getValues(data_set_name);
    }

    public List<MyList__c> getListSettings2(){
        return MyList__c.getAll().values();
    }
}
2
  • Hello Cruz i am not using lightning component. This is standard home page component. – Piyush Kumar Aug 3 '16 at 12:27
  • In that case use Devendra solution, also I will update my solution with an example of how to retrieve the custom setting from controller and assign it to a controller variable to use it later in your component. – D. Cruz Aug 3 '16 at 12:41

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.