Hot answers tagged

11

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-a-custom-button/ as an example (not my blog).


10

When you declare an actionFunction a javascript function name equal to actionFunction's attribute name named is declared and initialised on rendered visualforce page. Ex: <apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="showstate"> <apex:param name="firstParam" assignTo="{!state}" value="" /> </apex:...


10

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 getIsEnabled() { return Datetime.now().getTime() - start < 60 * 1000; } Integer count = 0; public Integer getCount() { return count; } public ...


9

Are your webservice calls being invoked asynchronously (via VF Remoting) or are they part of the page load (action method on the <apex:page>)? If they are being invoked via Visualforce Remoting, you can have a loading image immediately display on the screen and a callback for your VF Remote method that removes the image. If you are using the action ...


9

JSForce includes javascript access to the Metadata API. https://jsforce.github.io


8

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.method = "POST"; form.action = "https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8"; // Your org ID var elementOID = document....


8

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("core","1"); HTTPHeader.SetValue("Access-Control-Allow-Methods","POST"); HTTPHeader.SetValue("Access-Control-Allow-Origin","*"); </script>


7

So when you are using a actionFunction there are two ways you can access the value from the controller. You can use the assignTo attribute of the apex:param to set a variable in the controller. You can use Apexpages.Currentpage().getParameters().get('yourParamName') For your question How will be the request parameter firstParam sent to the controller ...


7

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 JS file and only kept the URLFOR exposed in the VF page to get the actual URL. Yep, this resource is nailed by a cross-origin restriction. Inspecting the ...


6

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) { V_SAMPLE_CANCEL.isSampleCancel = true; Sample_Order__c sot = new Sample_Order__c(Id=localId); sot.Status__C='Submitted'; ...


6

This can be done using the describeGlobal() method from the AJAX toolkit: <apex:page title="Object List"> <apex:pageBlock title="Object List"> <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem> <label for="object-list">Object List</label> <apex:...


6

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 a generic JavaScript framework that uses SOAP-based API calls to interact with salesforce.com. The reason why you have to include the AJAX toolkit is because it'...


6

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 single Remote action method and a page which using that method, see code: Apex Controller: public class ApexController { @RemoteAction public static ...


5

Create a button with Behavior of 'Execute Javascript', and content source of 'OnClick Javascript' {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} var myTask = new sforce.SObject("Task"); myTask.WhoId = "{!Lead.Id}"; myTask.Subject = "Walk-In-Visit "; sforce.connection.create([myTask]); window.location.reload();


5

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, Apex REST, and Lightning Out but not for making calls to Salesforce pages(as you are trying to do) because that is not exposed an API. I created a simple ...


5

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 to remember for anytime you are re rendering a container containing an SLDS SVG How to convert a Visualforce apex:pageMessages to be lightning style for ...


4

Since no one has posted an answer I'll have a go. As you suggest, the problem probably isn't the injection of the second page, but the DB call. There are a number of things you can do to reduce time in the DB such as the obvious narrowing your query, and adding indexes by way of making any fields involved in WHERE clauses indexed by using the "External ...


4

You can try to use a standard SFDC User object and a field called UserPreferencesApexPagesDeveloperMode: When true, indicates the user has enabled developer mode for editing Visualforce pages and controllers. (Source docs) Something like this: Boolean b = [Select UserPreferencesApexPagesDeveloperMode From User ...


4

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( 'SELECT NamespacePrefix FROM ApexClass WHERE Name = \'SomeClass\'', { onSuccess: function(data) { var prefix = data.records[0].NamespacePrefix? data....


4

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. This requirement applies to all Apex classes, including to classes that are exposed through Apex REST API. To enforce sharing rules for Apex REST API ...


4

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 sort of component notification or async operation, precisely because of the issues you just run into. Those were meant to be used by an application so you ...


4

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 getElementsByName method as shown below Get the button name and put the following code at the beginning of your button var btnService = document....


4

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 "User-Agent" to "SFAJAX 1.0", and Chrome rejects this setting and outputs an error (as should all modern browsers). It does not cause the script to stop running;...


4

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("c.findAll"); This is causing the action to be null and the reference to setParams to throw an error.


4

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/lightning/js_renderers.htm#afterRender_DOM I would put the logic into the Helper and just have the afterRender call your helper method. ({ afterRender: function(...


4

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 matches all controls that end with the specified string. Because you have the controls within an ‘apex:repeat’, both of your boxes end with the same string, and ...


3

I'm not sure whether the javascript side of things has the smarts to deal with the set or not, but you could just generate the full text query yourself: var setIds=new Array() //array of saleforce ids var ids = ''; $(sel).each(function() { ids = ids + '"' + $(this).attr('id') + '",'; }); if(ids.length > 1) { ids.substr(0, ids.length - 1); } var ...


3

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. <apex:pageBlockButtons location="top"> <apex:actionStatus id="commentSave"> <apex:facet name="start"> ...


3

Take a look at the Streaming API. You can have your VF page subscribe to a topic and get near real time updates. This blog post does a really good job walking you through setting it up on your page.


3

You can use some variable in controller and use that to show the record name. Like, take a string variable "RecordName" and once you have updated the selected record, set "RecordName" to the name of that selected record. Once this will be set, you can use that on the vf Page.


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