• Alvaro Collazo
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi All,

  Trying to construct the data table dynamically using visualforce remoting with jquery data table.
Getting the table with empty values.
The following is the code and output. Please help me in getting this done. 
 
<apex:page controller="AccountRemoter"  sidebar="false"  docType="html-5.0" >
    
    <head>
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"/>
        
        <apex:includeScript value="{!$Resource.Jquery2}"/>
        <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
        
        </head>
        
        <script type="text/javascript">
            $ = jQuery.noConflict();
        function getRemoteAccount() {
            
            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.AccountRemoter.getAccounts}',
                function(result, event){
                    console.log(result);
                    
                    $('#example').DataTable( {
                        data: result,
                        columns: [
                            { title: "Id" },
                            { title: "Name" }
                            
                        ]
                    } );
                }, 
                {escape: true}
            );
        }
        </script>
        <button onclick="getRemoteAccount()">Get Account</button>
        <table id="example" class="display" cellspacing="0" width="100%">
            
            
        </table>
        
    </apex:page>
 
global with sharing class AccountRemoter {

    public String accountName { get; set; }
    public static Account account { get; set; }
    public AccountRemoter() { } // empty constructor
    
   
    @RemoteAction
    global static List<Account> getAccounts( ) {
        List<Account> accnts= [SELECT Id, Name 
                   FROM Account  limit 5];
        return accnts;
    }
}

Output with empty data

Any help is really appreaciated . Thanks in advance.

Regards,
Naveen
Hi All,

  Trying to construct the data table dynamically using visualforce remoting with jquery data table.
Getting the table with empty values.
The following is the code and output. Please help me in getting this done. 
 
<apex:page controller="AccountRemoter"  sidebar="false"  docType="html-5.0" >
    
    <head>
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"/>
        
        <apex:includeScript value="{!$Resource.Jquery2}"/>
        <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
        
        </head>
        
        <script type="text/javascript">
            $ = jQuery.noConflict();
        function getRemoteAccount() {
            
            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.AccountRemoter.getAccounts}',
                function(result, event){
                    console.log(result);
                    
                    $('#example').DataTable( {
                        data: result,
                        columns: [
                            { title: "Id" },
                            { title: "Name" }
                            
                        ]
                    } );
                }, 
                {escape: true}
            );
        }
        </script>
        <button onclick="getRemoteAccount()">Get Account</button>
        <table id="example" class="display" cellspacing="0" width="100%">
            
            
        </table>
        
    </apex:page>
 
global with sharing class AccountRemoter {

    public String accountName { get; set; }
    public static Account account { get; set; }
    public AccountRemoter() { } // empty constructor
    
   
    @RemoteAction
    global static List<Account> getAccounts( ) {
        List<Account> accnts= [SELECT Id, Name 
                   FROM Account  limit 5];
        return accnts;
    }
}

Output with empty data

Any help is really appreaciated . Thanks in advance.

Regards,
Naveen
 public class soapSforceComSchemasClassAccountins {
 public class SessionHeader_element {
        public String x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ;
        private String[] x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ_type_info = new String[]{'00D90000000y0lh!AQ0AQGIsi542TCnp.73StsP8nawV5.7uVrHfVM0SyclcA.h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ','http://soap.sforce.com/schemas/class/AccountInsert',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert','true','false'};
        private String[] field_order_type_info = new String[]{'x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ'};
    }
    public class DebuggingInfo_element {
        public String debugLog;
        private String[] debugLog_type_info = new String[]{'debugLog','http://soap.sforce.com/schemas/class/AccountInsert',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert','true','false'};
        private String[] field_order_type_info = new String[]{'debugLog'};
    }
    public class AccountInsert {
        public String endpoint_x = 'https://ap1.salesforce.com/services/Soap/class/AccountInsert';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public soapSforceComSchemasClassAccountins.SessionHeader_element SessionHeader;
        public soapSforceComSchemasClassAccountins.DebuggingInfo_element DebuggingInfo;
        public soapSforceComSchemasClassAccountins.CallOptions_element CallOptions;
        public soapSforceComSchemasClassAccountins.DebuggingHeader_element DebuggingHeader;
        public soapSforceComSchemasClassAccountins.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
        private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/AccountInsert';
        private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/AccountInsert';
        private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/AccountInsert';
        private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/AccountInsert';
        private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/AccountInsert';
        private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert', 'soapSforceComSchemasClassAccountins'};
        public void opportunityUpdate(String Name,String AccountNumber,String Description) {
            soapSforceComSchemasClassAccountins.opportunityUpdate_element request_x = new soapSforceComSchemasClassAccountins.opportunityUpdate_element();
            request_x.Name = Name;
            request_x.AccountNumber = AccountNumber;
            request_x.Description = Description;
            soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element response_x;
            Map<String, soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element> response_map_x = new Map<String, soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://soap.sforce.com/schemas/class/AccountInsert',
              'opportunityUpdate',
              'http://soap.sforce.com/schemas/class/AccountInsert',
              'opportunityUpdateResponse',
              'soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element'}
            );
            response_x = response_map_x.get('response_x');
        }
}

}
executing through Developer Console from other Salesforce Org:::

soapSforceComSchemasClassAccountins.AccountInsert a = new soapSforceComSchemasClassAccountins.AccountInsert();
a.opportunityUpdate('Microsoft','21232','Cognizant');

Line: 111, Column: 1
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: 

INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=