1

In apex, normally we can consider retrieving info from a custom setting just like an object using query. But the simpler way remain the use of the getInstance method. But I want to use javascript remote object to get a paticular value from a field from my custom setting, how do i achieve this ?

This is a sample I came across for normal object :

   var wh = new SObjectModel.Warehouse();
   ct.retrieve({where: {FirstName: {eq: 'Marc' }}}, function() {});
0

Got it to work.

In my page i have this :

    <apex:remoteObjects >
         <apex:remoteObjectModel name="CS_WebServiceDetail__c" jsShorthand="csSetting" fields="Name,Id" >  
         <apex:remoteObjectField name="PaginationCount__c" jsShorthand="count"/>
    </apex:remoteObjectModel>
</apex:remoteObjects>

where CS_WebServiceDetail__c is my custom setting and PaginationCount__c is the field i need on my custom setting.

Then in my script, I have this :

   var cs01 = new SObjectModel.csSetting();
    console.log('cs01',cs01);

    cs01.retrieve({where: {Name: {eq: 'setting01'}}}, function(err, records){           
        if(err) console.log('error while retrieving count per page',err.message);
        else {      
           console.log('retrieving the count for ',records);
           records.forEach(function(record) {
               count = record.get("count");
           });
        }
    });

In this example I am retrieving from my custom setting using the unique name. Even if the name is unique the result will be an array of object.

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.