Hot answers tagged

11 votes
Accepted

Ajax custom button calling apex method errors out

You must use the webservice keyword to generate a service, and it must be static, since it won't be considered constructed. See http://teachmesalesforce.wordpress.com/2011/05/02/call-apex-code-from-...
  • 445k
11 votes
Accepted

Possible to Set Access-Control-Allow-Origin in an SFMC Landingpage?

I found out a Solution. Its possible to Set the Header using Server-Side JavaScript within the Landingpage. Here is my Header and its working fine now. <script runat=server> Platform.Load("...
10 votes
Accepted

How To Stop actionPoller After Set Duration?

You can tweak the example from the docs just slightly to check an isEnabled property. Controller public with sharing class Demo { final Long start = Datetime.now().getTime(); public Boolean ...
  • 144k
9 votes
Accepted

Is there a Javascript Wrapper Salesforce Metadata API?

JSForce includes javascript access to the Metadata API. https://jsforce.github.io
  • 4,976
7 votes
Accepted

AJAX load JSON from static resource

I've actually kind of figured it out. There is some issue with my use of $.getJSON, however $.ajax works fine. I'll explore why .getJSON wasn't working.. Either way, I've moved my code back into the ...
6 votes

Custom Button that will change a field in a custom object and consequently invoke before update trigger on the same object

In order to trigger the trigger you need to actually save the record to the database. So update your code to this: global class ABV_SMPORD{ webservice static void submitSMPORD(Id localId) { ...
6 votes
Accepted

Using AJAX in Salesforce

This can be done using the describeGlobal() method from the AJAX toolkit: <apex:page title="Object List"> <apex:pageBlock title="Object List"> <apex:pageBlockSection ...
  • 18k
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 ...
  • 445k
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 ...
5 votes
Accepted

CORS whitelisting not working as expected

Ok. I did some research on this and looks like we both interpreted the Salesforce CORS documentation wrongly. Salesforce CORS says that CORS is only for making requests to Supported Salesforce APIs, ...
  • 8,447
5 votes

visualforce page ActionFunction reRender not Working

You can absolutely rerender the <use>and <svg> tag by: The xmlns= on the div containing the SVG is a MUST as if you try to rerender without it the page will simply stall. Important trick ...
  • 53.3k
4 votes
Accepted

Get class' namespace prefix to use in a Ajax call

Instead of calling Apex Code through executeAnonymous, I'd suggest one of two other suggestions: (A) Call the API directly. There's no reason why you can't simply: sforce.connection.query( '...
  • 445k
4 votes

Respecting sharing settings when using jquery post

This Exposing Data with Apex REST Web Service Methods page includes the statement: Also, sharing rules (record-level access) are enforced only when declaring a class with the with sharing keyword....
  • 131k
4 votes

ActionStatus firing an event Twice on VF Page

Like what BritishBoyInDC wrote, this is restricted to pageBlockButtons. As a workaround, if you add location="top" (or bottom) to your pageBlockButtons element, the event will only fire once. ...
4 votes
Accepted

Are aura:waiting and aura:doneWaiting component specific events?

Yes both aura:waiting and aura:doneWaiting are application level events. Those events are kind of legacy from the very first design of the framework years ago, and we do not recommend its use for any ...
  • 1,262
4 votes
Accepted

Disable Custom Button in Standard Page Layout

Custom button this event point to window property in javascript so we can't use that to disable the button but as an alternative option we can search for that button using standard javascript ...
  • 10.4k
4 votes

Refused to set unsafe header "User-Agent": connection.js

The XMLHttpRequest#setRequestHeader specifically states that User-Agent must not be set by a client script, and any attempt to set that header should be ignored. The connection.js script tries to set "...
  • 445k
4 votes
Accepted

Custom Search Lightning component cannot read property. (community)

Assuming that findAll is the remote method in your controller, I believe that your line in ContactListController.js: var action = component.get("e.c.findAll"); should be: var action = component.get(...
4 votes

Lightning component lazy loading

You could put the request for the data of the picklist into the Renderer. Make an afterRender method that populates the picklist. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/...
4 votes
Accepted

Jquery AutoComplete in Visualforce Page

This is not really a SFDC question, but I’ll tackle it anyway. On your JavaScript, your return code searches for the controls to update by using the jQuery selector $ (as in id$=“conName”). This ...
3 votes

Rerender page components from apex:component

Here is one possible solution that can be filed under - It's Ugly, But It Works. On the Visualforce page, add an actionFunction that is connected to a no op method and rerenders the pageBlock that ...
3 votes

Uncaught reference error: sforce is not defined

Can you try this. <script src="/soap/ajax/32.0/connection.js" type="text/javascript"/> <script src="/soap/ajax/32.0/apex.js" type="text/javascript"/> <apex:includeScript value="{!$...
  • 734
3 votes

Correct way of using apex:actionPoller

Give it inside: <apex:pageBlock title="New Cases"> <apex:actionPoller rerender="ncase" interval="15"/> </apex:pageBlock>
  • 1,456
3 votes
Accepted

Instantiating a field of an sObject with a string value passed through AJAX

The solution to this is to use sObject method put. public static String updateInputField(Id objectkId, String objectFieldName, Integer objectFieldValue) { String errorMsg = 'testerror'; ...
  • 63.8k
3 votes
Accepted

How do I load Bing Maps in Visualforce?

The problem is that Visualforce does not preserve your body onload replacing that with its own logic. (Worth using your browser's "View Source" or "Inspect" feature to look at the HTML that the ...
  • 131k
3 votes

How do I load Bing Maps in Visualforce?

Keith C is right. <body onload= will not work. You can call your GetMap method from window.onload as below. I just updated your code and it is working. Also you need a key to use the Map. <...
  • 13.6k
3 votes
Accepted

Set timeout always 10 seconds for remoteFunction

See Execution Governors and Limits (emphasis mine): Per-Transaction Apex Limits Maximum CPU time on the Salesforce servers5 Synchronous Limit: 10,000 milliseconds Asynchronous Limit: 60,000 ...
  • 144k
3 votes
Accepted

Assertion Failed on custom object - Lightning component

As discussed in comments, you should be using competitor instead of competitor__c from var="competitor". Another situation in which this same error comes, when you forget to put the "v" i.e value ...
  • 234
3 votes
Accepted

What is the standard way to save to the database after a Web Call?

Insecure endpoint sounds like you are using http instead of https. You can schedule time with someone on the AppExchange team to review your issues and get feedback.
3 votes
Accepted

run assignment rule from javascript button

Looks like AssignmentRuleHeader is case sensitive, Try changing it to assignmentRuleHeader. Your code would then be: sforce.connection.AssignmentRuleHeader = {} sforce.connection....
  • 18k

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