• Swapnil Pal 1
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
“Have been trying to learn Javascript Remoting since hours. I have manipulated this example to display a table of records with remoting an apex class. Following is the controller and VF.. My controller pulls all records from custom object Feedback. But i'm unable to display in VF. Please guide.

global with sharing class AccountRemoter {

public String accountName { get; set; }
public Feedback__c account { get; set; }
public AccountRemoter() { }

@RemoteAction
global static List<Feedback__c> getAccount(String accountName) {
List<Feedback__c> account = [SELECT Name FROM Feedback__c ];
return account;
}
}
and the Visualforce page...

<apex:page controller="AccountRemoter">
<script type="text/javascript">
function getRemoteAccount() {
    var accountName = document.getElementById('acctSearch').value;

    Visualforce.remoting.Manager.invokeAction(
        '{!$RemoteAction.AccountRemoter.getAccount}',
        accountName,
        function(result, event){
            if (event.status) {
                // Get DOM IDs for HTML and Visualforce elements like this
                document.getElementById('remoteAcctId').innerHTML = result.Id
                document.getElementById(
                    "{!$Component.block.blockSection.secondItem.acctNumEmployees}"
                    ).innerHTML = result.NumberOfEmployees;
            } else if (event.type === 'exception') {
                document.getElementById("responseErrors").innerHTML =
                    event.message + "<br/>\n<pre>" + event.where + "</pre>";
            } else {
                document.getElementById("responseErrors").innerHTML = event.message;
            }
         },
         {escape: true}
     );
   }
  </script>

    <input id="acctSearch" type="text"/>
    <button onclick="getRemoteAccount()">Get Feedbacks</button>
    <div id="responseErrors"></div>

    <apex:pageBlock id="block">
    <apex:pageBlockSection id="blockSection" columns="2">
        <apex:pageBlockSectionItem id="firstItem">
            <span id="remoteAcctId"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem id="secondItem">
            <apex:outputText id="acctNumEmployees"/>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:page>
The closest to a table on click of the "Get Feedback" button, I have achieved so far with undefined results.... enter image description here

Any help will be appreciated. Thanks

UPDATE: Fields in Feedback

Client_Feedback_App__c

Description__c

Importance__c

Resolution__c

Status__c

Summary__c
  • April 15, 2014
  • Like
  • 0