66

Part 1 Correct. You cannot "automatically" enforce field level security or profile permissions with "with sharing," as this would make code much more difficult to debug because of failures. This is noted in Using the with sharing or without sharing Keywords, under the second note. Correct. This means that if do not specify "with ...


57

This will print the date out in the format December 14, 2013. The documentation can be found here <apex:outputText value="{0, date, MMMM d',' yyyy}"> <apex:param value="{!contact.Birthdate}" /> </apex:outputText> or if all you need is the current date printed out in that format then you can use this: <apex:outputText value="{0, ...


49

Visualforce pages work like this. The browser makes a request and Salesforce uses Visualforce tags to generate HTML/CSS/JavaScript that is sent back to the browser. Most communication is in a simple text format so can be looked at. The browser builds a DOM (Document Object Model - an in-memory tree) from the response and renders that onto the screen guided ...


46

You can use the recently introduced pass through attributes for this: <apex:inputText value="{!username}" id="username" html-placeholder="Username"/> <apex:inputSecret value="{!password}" id="password" html-placeholder="Password"/> PS Cool page that lets you know Can I use input placeholder attribute?


45

This is just a syntax issue, your condition will work if you make a few small changes Change <!-- doesn't work, this is apex, not a formula as required --> <apex:pageBlockTable ... rendered="contacts.size()>0"> To <apex:pageBlockTable ... rendered="{!contacts.size>0}">


39

Update: Spring '21 Release (API v51+) adds new SOQL FIELDS function can select all fields of an object. Refer to documentation Knowing that new FIELDS function must have a LIMIT of at most 200, when used with ALL or CUSTOM keyword, the workaround below can still be useful. There is no way to Select * with SOQL. You can however work-around this limitation ...


39

The Salesforce JSON.deserialize(String, Type) method cannot deserialize from JSON into generic Object, or into objects with generic Object fields, it can only deserialize into concrete types with fields that have concrete type. Everywhere the you have defined your field types as Object, e.g. public Object CellphoneNumber, you need to replace Object with the ...


38

Definition User Mode - Profile level permissions, field-level security, and sharing rules of the current user are enforced. System Mode - Object permissions, field-level security, sharing rules aren't applied for the current user. This is the consolidated list of execution and mode of execution: Trigger - System Validation Rule - System Auto ...


35

@RemoteAction and apex:actionFunction are essentially polar opposites in terms of functionality, even though they both offer JavaScript functionality. @RemoteAction methods are static, and therefore can't see the current page state directly, while apex:actionFunction methods are instance methods, and so can see the entire page state. @RemoteAction methods ...


34

I realize this is a little late in coming, but for posterity's sake, if you append the namespace to the front of your visualforce page name, salesforce will make sure it gets the proper namespace in the full url. So if you want your action to go to /apex/MyPage, you would do this: /apex/c__MyPage If you're linking to something in a managed package you ...


33

Although this question isn't well defined enough for this site which is typically focused at solving specific issues, I do think there's merit in building up a guide to the best resources so I'm going to make the question and this answer community wiki. Trailhead As of late 2014, by far one of the best options for getting up to speed on the platform is ...


33

Using above solution i.e. "apex:form html-novalidate" will disable all validations for all command buttons including buttons like "Save". It would be best to disable validations only on press of CANCEL button, which could be achieved in an isolated way on CANCEL button only i.e. <apex:commandButton action="{!cancel}" value="Cancel" immediate="true"      ...


33

The Visualforce for this situation is this: <apex:repeat value="{!myMap}" var="fieldKey"> key: {!fieldKey } value: {!myMap[fieldKey]} </apex:repeat> because the map key is automatically used by the apex:repeat and square brackets are the expression language way of looking up a value in a map. PS Most of the time the lack of ordering ...


31

Good news everybody! This has just been added to the Winter '16 release. It can be used like this: someSObject.recalculateFormulas(); From the Documentation: Recalculates all formula fields on an sObject, and sets updated field values. Rather than inserting or updating objects each time you want to test changes to your formula logic, call this ...


30

If you can make due with JavaScript checking you can use the method outlined in this documentation that looks for the sforce JavaScript object, and just adapt it to do your work. if( (typeof sforce != 'undefined') && (sforce != null) ) { // do your SF1 mobile button stuff } else { // do your desktop stuff } There isn't an official way to do ...


28

There are multiple solutions for this question. 1. Use of hidden field You can define an apex variable and associate it in a hidden input field on the visualforce page. Then set a javascript variable to this field an reference it in controller: Apex class: public class myClass { // Our test variable public String myString {get; set;} ...


28

Contrariwise, I will provide an argument for upgrading, although the other answers state that complacency is acceptable. There are two factors at play when you speak of API versions: features and consistency. Both of these issues introduce two distinct needs, namely stability and flexibility. First, let's address consistency. You should keep all your ...


27

PDF files are binary files, and as such, we can't just load it up into a string directly and examine the data to determine if a signature marker is present; it would probably require too much processing time on all but simple PDFs anyways (those less than about 1mb). However, we can check against a simple heuristic that will tell us, with fair likelihood, if ...


25

Javascript remoting can be used within a static resource. This method fails in a static resource because of the use of the merge field '{!$RemoteAction.MyJSRemoteController.getContentList}' and not because of the use of javascript remoting. Using the alternate javascript remoting syntax below will work because it is not dependent on a merge field: ...


25

Visualforce Charts are rendered by JavaScript after the page has been initially rendered. PDF does not support JavaScript, and so those charts never have a chance to render before the PDF file is created. This is in direct contrast to Google Charts, which are rendered as images on the Google server before being delivered. You will need to use a image-based ...


25

You don't need to add lightning css as static resource. Just include this tag on top of your VF page: <apex:slds />. Pass the icon reference directly as shown below: /apexpages/slds/latest/assets/icons/standard-sprite/svg/symbols.svg#opportunity Example: <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/apexpages/...


24

It is sent to salesforce as a name,value pair. If it doesn't have a name, it isn't available. It is not required because <apex:param> has other uses to like in <apex:outputText>. The value is therefore the only required field.


24

Thanks to everyone in the community for calling this to our attention. We've noticed that some of our documentation has fallen out of Google's index, or fallen below first-page results. We're currently investigating what may have caused this. We did release our Summer 17 (API v40.0) documentation on Monday 22 May, and are trying to determine if anything ...


23

Accessing controller properties uses the usual get & set syntax. Set in a constructor and retrieved using the shorthand notation public class YourController { public string varA { get; set; } // use the proper type public YourController() { varA = 'Some text'; } } or Retrieved from the getNNN mechanism public class ...


23

In the Salesforce Spring 16 release, there will be global variables and apex methods you can call to detect the user's UI theme context. This may make it easier for developers to detect the user's experience without relying on the existence of certain javascript objects or URL parameters. http://docs.releasenotes.salesforce.com/en-us/spring16/release-notes/...


23

Note that this component is only available starting with API Version 39.0. If you try to include it in API Version 38.0 and below, it will not be available.


22

Yes it is feasible. Just think of Salesforce as a (quirky) web server where you have to wrap your Angular index web page in: <apex:page showHeader="false" sidebar="false" standardStylesheets="false" applyHtmlTag="false"> <html lang="en" ng-app="myApp" ng-controller="MyAppController"> .... </html> </apex:page> And you ...


22

You should use the XML comment syntax, which is: <!-- This is a comment -->


22

Visualforce is never going away. The barrier to entry with lightning is far too high for the "anybody can code" group that salesforce really likes to cater to. PDF rendering and email templates are also never going away. That said, I do see a lot more lightning in the future, but considering how much freedom you get with visualforce (no LockerService, no ...


22

SUMMER '18 UPDATE You can now use the getRecordTypeInfosByDeveloperName() to get a Record Type Id by Developer Name without spending a SOQL query. This should be the preferred approach going forward instead of using the old getRecordTypeInfosByName() method as suggested in the original answer. Use this approach instead of the old suggestion below, unless ...


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