2

See my code comments in my controller for what I'm trying to do. This article might help as well: Overriding Default Remote Objects Operations

Page

    <apex:page>
    <apex:remoteObjects >
        <apex:remoteObjectsjsNamespace="RemoteObjectModel">    
        <apex:remoteObjectModel name="Opportunity" fields="Id,isWon"/>  
    </apex:remoteObjects>

    <script>
        var opp = new RemoteObjectModel.Opportunity();
    opp.retrieve( 
        { where: { 
            isWon: {eq: FALSE} 
          }, 
          orderby: [ {Id: 'ASC'} ],
          limit: 1 },  

        function(err, records) { 
            if (err) { 
                alert(err); 
            } else { 
                console.log(records.length); 
                console.log(records[0]); 
            } 
        } 
    );
    </script>
</apex:page>

Controller:

 public class overrideRemoteObjectOperations{

        @RemoteAction
        public static Map<String,Object> retrieve (String type, Map<String,Object> fields){
            //i dont know how to do this, but i am overriding the retrieve method because I think we need to.
            //My goal is to eliminate the hardcoding of FALSE in the visualforce page logic:  isWon: {eq: FALSE} 
            //i want the retrieve method to re-query (either on button click or checkbox-change) 
            //so that isWon is filtered by the boolean value that the user selects on the page.
            //Adding the boolean/checkbox to the visualforce page needs to be part of the answer as well.

        }

    }

Any examples? Thank you,

  • Based on your other answer, I have faith that using variables in remoteobjectmodel WHERE clause is feasible. As such, my plan is to add a custom controller to my visualforce page, then add input fields to the page and use my custom controller to override the retrieve() operation. The overrided retrieve() method will merge the values from the users' input selections into the WHERE clause within the custom controller's retrieve() override method. – Peter Noges Sep 16 '17 at 19:34
  • hey @sfdcfox! i added my code and updated the question. I'm very appreciative of your expertise here. – Peter Noges Sep 17 '17 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.