You need to sign in to do that
Don't have an account?
axtria.alignmax1.3922801576877412E12
access salesforce map in javascript
I've a requirement in which i want to return a salesforce map from remoteaction fuction to javascript function
Not able to loop through the response returned.
Can anyone help me on it?
Thanks
Not able to loop through the response returned.
Can anyone help me on it?
Thanks
Salesforce JavaScript Remoting: Using Apex and JavaScript objects to pass data from client- to server-side and vice versa
JavaScript Types to Apex Equivalents
This is a little tricker, especially when it comes to sObjects. Note that the approach below works for classes and sObjects too.
The Visualforce Page
<apex:page controller="RemotingObjectsController">
<script>
/* Define a JavaScript Object that looks like an Account */
/* If you were using custom objects the name must include the "__c" */
function Account(){
/* Note the field names are case-sensitive! */
this.Id = null; /* set a value here if you need to update or delete */
this.Name = null;
this.Active__c = null; /* the field names must match the API names */
}
var acc1 = new Account();
acc1.Name = 'Tquila';
acc1.Active__c = 'Yes';
var acc2 = new Account();
acc2.Name = 'Apple';
acc2.Active__c = 'Yes';
var accounts = new Array(acc1, acc2);
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.RemotingObjectsController.insertAccounts}',
accounts,
function(result, event) {
console.log(result);
});
</script>
</apex:page>
The Controller
There not much to the controller in this case.
public with sharing class RemotingObjectsController {
@RemoteAction
public static void insertAccounts(List<Account> accounts){
insert accounts;
}
}
http://th3silverlining.com/2012/06/22/salesforce-javascript-remoting-using-apex-and-javascript-objects-to-pass-data-from-client-to-server-side-and-vice-versa/
Regards,
Ashish