15
votes
Accepted
What is the correct way to send an Apex type containing DateTime members to RemoteActions?
To send a DateTime field defined on a custom Apex class from JavaScript to Apex using Visualforce Remoting you need to use toUTCString().
You can create a JavaScript Date object from a Unix time ...
- 13.5k
13
votes
Accepted
How is heap size calculated?
Salesforce uses SI megabytes in all of their documentation, not SI mebibytes. This is confusing for Windows users and hardware programmers, who are used to seeing mebibytes called megabytes, and may ...
- 462k
10
votes
Accepted
Javascript Remoting returning JSON with encoded characters. For example &
The RemoteAction framework auto-escapes the results by default, to prevent accidental XSS injections for developers using innerHTML to render the contents of a callback. This is a security feature, ...
- 53.6k
9
votes
Accepted
JavaScript button to call the Apex method is not working
Your syntax is wrong. You should collect all parameters within one {...} block:
sforce.apex.execute("IFE/IFE_ButtonMethods",
"createIQuoteAcc",
{oppID:"{!...
- 21.8k
9
votes
Accepted
Javascript remoting for Apex
As for CSRF, @ca_patterson has already answered that on Javascript Remoting CSRF.
As for users interacting directly with the methods, it certainly is possible, if someone has the correct knowledge. ...
- 147k
8
votes
Accepted
how to call a generic @RemoteAction from different VF Pages?
If you have the remote action in a class called MyRemoteClass
global class MyRemoteClass{
@RemoteAction
global static string sayHello(String val){
return 'Hello ' + val;
}
}
...
- 53.6k
8
votes
Accepted
salesforce code review best practices for controllers
As you are asking about classes used as controllers, in addition to other code review items the idea of "thin controllers" should be considered. This isn't an idea that is unique to the Salesforce ...
- 133k
8
votes
Is it possible to make a synchronous Visualforce remoting call?
No. The framework requires a callback function, and it will always run asynchronously. Besides, it's now deprecated in most browsers (you'll get warnings in the console), so you shouldn't try to make ...
- 462k
7
votes
Accepted
How to create Map<String,List<String>> in Javascript?
You have to create the key as an array, first.
// Create an empty Object
var aMap = {};
function addValueToKey(key, value) {
// Shorcut || returns left side if it is "truthy," or the ...
- 462k
7
votes
How can I stop JavaScript remoting reloading page
By default, a button will cause a form submit. You have to prevent this default either by cancelling the default behavior, or by returning "false" from your handler. The easiest method is to simply do ...
- 462k
7
votes
Accepted
how to convert ' ; to single quote in apex
' is escaped HTML Entity, just like (, &, and so on. To unescape most of them in Apex use String.unescapeHtml4() method which
Unescapes the characters in a String using HTML 4....
- 7,316
6
votes
How to pass JavaScript array to Apex controller
You can use ActionFunction for this. Here is sample for your reference.
Controller:
public class ActionFunctionCLS {
public void IWantToDebug() {
list<String> ls = ( List<...
- 9,050
6
votes
Accepted
Is it possible to execute remote functions in order?
Put the second invocation inside the callback of the first invocation. It's as simple as moving the second block of code directly into the function where you typed "second function call should happen ...
- 462k
6
votes
Accepted
Javascript remoting not hitting apex?
The problem is with this line right here:
'{ct_4_sf.RecordingTest.saveRecording}',
You should be using the $RemoteAction merge value, like this:
'{!$RemoteAction.RecordingTest.saveRecording}',
...
- 462k
6
votes
salesforce code review best practices for controllers
One must follow the coding guidelines and best practices as mentioned in this great resource.
https://developer.salesforce.com/page/Apex_Code_Best_Practices
To facilitate Code Review options, You can ...
- 673
6
votes
Javascript remoting for Apex
Cross-Scripting Protection
There's a CSRF token that has to be presented in the payload:
{ "action":"myns.remote",
"method":"method",
"data":null,
"type":"rpc",
"tid":2,
"ctx": { "csrf": "...
- 462k
6
votes
Accepted
JavaScript Remoting for Apex Controllers
The difference is that in the first example the class name was added directly:
TestCtrl.sayHello...
And in the second example the $RemoteAction expression was used.
Why? Suppose you have an org ...
- 21.8k
6
votes
Accepted
what happens behind the scenes of salesforce remoting
The AJAX Toolkit is a generic toolkit that is designed to be used anywhere: in a JavaScript button, on your own website, in a Chrome/Firefox/IE browser extension, desktop apps, NodeJS apps, etc. It's ...
- 462k
6
votes
what happens behind the scenes of salesforce remoting
This question is really interesting, which also force me to think, what's there exactly, and how it works, here is the background:
let's understand this process with an example, I created a Class with ...
- 747
5
votes
Accepted
Odd JS Remoting Behavior
Now, my question is whether or not this call will function as intended
when the app is packaged:
Visualforce.remoting.Manager.invokeAction("MyController.myAction",param, function(result) {
.......
- 9,453
5
votes
Accepted
page navigation
You should take a look at Creating Visualforce Pages That Work in Mobile and Desktop. Here is their basic example:
if( (typeof sforce != 'undefined') && (sforce != null) ) {
// ...
- 147k
5
votes
Accepted
How to Use Javascript Remoting Namespace From Managed Package
The simplest way to have a conditional namespace in a remote action invocation is like this:
(namespace||window).controller.method(
...
);
- 6,891
5
votes
Accepted
Polling in lightning component
Is this truly a polling event, or could it handled via PushTopics? If it is based on the value changing on a record, consider using PushTopics.
For polling, setTimeout and setInterval work, just be ...
- 2,580
5
votes
Accepted
Calling a @RemoteAction method from a class that is NOT your controller
Try adding the other class as an extension in your opening <apex:page> tag. You can do this for multiple classes by separating them with commas.
<apex:page controller="SomeApex_Controller"
...
- 3,316
5
votes
Accepted
Dynamically get required fields with JS Remote Objects
I approach a similar problem in my SObjectFactory test utility with a RequiredFieldsCache, but you can adopt a somewhat simpler approach because you don't care about the values for a particular field.
...
- 147k
5
votes
Accepted
Site.changePassword returns null when called using javascript remoting
The methods of the Site class are designed to work from Visualforce and within a Site so it is possible that the call can't be made to work in your situation. If the context was Visualforce, errors ...
- 133k
5
votes
How is heap size calculated?
You have more in the heap than just file data. Heap can be tricky to measure anyway because of garbage collection but you can see how much data you added by taking a diff:
Integer startingHeap = ...
- 147k
5
votes
Accepted
Visualforce Pagination and Viewstate
If you're going to use remoting, consider grabbing of the ID values, then grab the records you need when you need to load a page. All of this happens client-side. Here's what your controller might ...
- 462k
5
votes
Tightening security around Javascript Remoting from Visualforce
Even if you could reliably authenticate that the incoming call came from a Visualforce page the next step would be to invoke the Javascript Remoting API from something like the browser's developer ...
- 22.5k
4
votes
Accepted
Multiple Remoting Controllers for SPA
Yes
//apex
global class xGlobal {
@RemoteAction
global static string doAction1( string JSONData ) {
return class1.doAction(JSONData );
}
global static string doAction2( string ...
- 91
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
javascript-remoting × 393visualforce × 188
javascript × 137
apex × 132
remote-action × 40
jquery × 13
remote-objects × 13
ajax × 11
angularjs × 10
controller × 8
json × 8
visualforce-component × 8
lightning-aura-components × 7
actionfunction × 7
soql × 6
rest-api × 5
managed-package × 5
salesforce1-app × 5
error × 5
security × 5
governorlimits × 5
javascript-controller × 5
ajax-toolkit × 5
community × 4
force.com-sites × 4