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 ...
user avatar
  • 13.2k
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 ...
user avatar
  • 430k
11 votes
Accepted

When to use Apex controller vs JS Remoting or REST

There's no one true path! But you've already touched on a couple interesting points like the historical availability of Visualforce on various devices. I like to compare and contrast from the ...
user avatar
10 votes

Javascript Remoting in Static Resource

To add to Phil's answer, you can use Javascript remoting in a static resource. However, the only tricky issue is namespacing. There are very few good examples of the alternate javascript remoting ...
user avatar
  • 1,613
10 votes
Accepted

Javascript Remoting returning JSON with encoded characters. For example &amp

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, ...
user avatar
  • 53.1k
9 votes

Accessing Non-Static Variables in Static Methods of a Visualforce Controller

The short answer is quite simply, you cannot get to the instance of the Apex class that was invoked on page load. It is gone. You are bumping up against one of the architectural peculiarities of ...
user avatar
  • 19.1k
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:"{!...
user avatar
  • 21.7k
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. ...
user avatar
  • 142k
8 votes

How do I use Javascript or jQuery externally to send data to Salesforce Leads?

You can do this from JavaScript using Web-to-Lead (as suggested in a comment by greenstork): function webToLead(firstName, lastName, email) { var form = document.createElement("form"); form....
user avatar
  • 16.2k
8 votes
Accepted

Does Javascript Remoting Count Towards API Limits?

No, JavaScrpit remoting does not constitute an API call.
user avatar
  • 14.5k
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; } } ...
user avatar
  • 53.1k
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 ...
user avatar
  • 129k
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 ...
user avatar
  • 430k
7 votes
Accepted

pass blob from javascript to apex

You can't directly construct Blobs through remoting right now. You are basically limited to things that you can put in JSON, which means that you need to make the payload binary-safe. Encode the ...
user avatar
  • 430k
7 votes
Accepted

Javascript Remoting - sending sObject as argument

EDIT 2: I've also just noticed that you're passing a formatted date string, with Visualforce Remoting you need to pass your Date values as Unix timestamp values (in milliseconds, rather than seconds)....
user avatar
  • 13.2k
7 votes
Accepted

Javascript remoting: to invokeAction or not to invokeAction

The main difference that I know of is that the invokeAction call will automatically resolve namespaces for you. For example, if your remote method is in a class within a namespace the second method ...
user avatar
  • 13.2k
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 ...
user avatar
  • 430k
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 ...
user avatar
  • 430k
7 votes
Accepted

how to convert &#39 ; to single quote in apex

&#39; is escaped HTML Entity, just like &#40;, &amp;, and so on. To unescape most of them in Apex use String.unescapeHtml4() method which Unescapes the characters in a String using HTML 4....
user avatar
6 votes

Onblur issue on text box autocomplete..?

I'm finding it hard to interpret your question. Can you provide more code examples? I think you're using blur() wrong. Wouldn't you want to use a typing timer? Something that queries for auto-...
user avatar
6 votes
Accepted

Visualforce remote objects

The Apex Developer’s Guide has a section Best Practices for Using Remote Objects that is very well written and, generally, addresses what Remote Objects are good for and what they aren’t. Here is ...
user avatar
  • 28.6k
6 votes
Accepted

VFRemoting escape option

what is the best place to handle escaping (html encoding) when using VF Remoting? In your JavaScript framework, not in the transport. This is the responsibility of your template parser or output ...
user avatar
6 votes
Accepted

ORs and ANDs in the retrieve function of Visualforce Remote Objects

OPTION 1: Nested logical constructions to prevent the clash of identifiers where: { or: { BillingState: { eq: 'Hawaii' }, or: { BillingState: { eq: 'Alaska' }, or: {...}, }, ...
user avatar
  • 33.5k
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<...
user avatar
  • 8,979
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 ...
user avatar
  • 430k
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}', ...
user avatar
  • 430k
6 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( ... );
user avatar
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 ...
user avatar
  • 663
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": "...
user avatar
  • 430k
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 ...
user avatar
  • 21.7k

Only top scored, non community-wiki answers of a minimum length are eligible