Enforcing Sharing Rules. Apex generally runs in system context; that is, the current user's permissions, field-level security, and sharing rules aren’t taken into account during code execution.
Because these rules aren't enforced, developers who use Apex must take care that they don't inadvertently expose sensitive data that would normally be hidden from users by user permissions, field-level security, or organization-wide defaults. They should be particularly careful with Web services, which can be restricted by permissions, but execute in system context once they are initiated. Most of the time, system context provides the correct behavior for system-level operations such as triggers and Web services that need access to all data in an organization. However, you can also specify that particular Apex classes should enforce the sharing rules that apply to the current user. DML Statements vs. Database Class Methods. Apex offers two ways to perform DML operations: using DML statements or Database class methods.
This provides flexibility in how you perform data operations. Blog.: Force.com object and record level security. Lately I've been involved in several discussions around how the Force.com platform handles object and record level security.
I'm surprised that there's still a lot of confusion around this topic despite all of documentation available out there so I'll try to explain this topic in more detail. It usually helps to start the conversation referring to Jason Ouellete’s “Development with the Force.com Platform” book where he illustrates these layers of security as a funnel. Each request has to go through several layers starting with CRUD and FLS checks and then moving to verifying org-wide default sharing model and any exceptions to org-wide sharing model if applicable. SFDC4Developer: "Setup" objects and "Non-setup" objects in SFDC. There are two types of objects that you can interact with on the platform.
One is "setup" object and the other is a "non-setup" object. A "setup" object is one that must be edited from the setup or builder area of the platform. Setup objects are * User * RecordType * Profile etc and all other general objects i.e. * Contact * Account * Lead are the None setup objects. Secure Coding Storing Secrets. What Is It?
Sensitive data can include: Passwords Passphrases Encryption keys Purchase instruments, such as credit card numbers Personal contact information such as names, phone numbers, email addresses, account usernames, physical addresses, and more Demographic information such as income, gender, age, ethnicity, education In some states and countries: machine identifying information such as MAC address, serial numbers, IP addresses, and more Sensitive data is also called personally-identifying information (PII) or high business impact (HBI) data. What is considered sensitive data varies greatly from state to state and country to country. Various compliance standards, such as the Payment Card Industry (PCI) compliance standard, require special steps to be taken when collecting sensitive data in order to stay in compliance.
Salesforce.com Integrations External applications should not store Salesforce.com user credentials (usernames, passwords, or session ID's) in external databases. Apex Developer Guide. SOQL for loops iterate over all of the sObject records returned by a SOQL query.
The syntax of a SOQL for loop is either: or Both and must be of the same type as the sObjects that are returned by the . As in standard SOQL queries, the  statement can refer to code expressions in their WHERE clauses using the : syntax. For example: The following example combines creating a list from a SOQL query, with the DML update method.
Apex - Rollback whole Batch on error. One possible solution I can think of is a staging object as an intermediate step and chained batch executions.
Let's say you're doing something with Accounts. First create a custom object called Account_Batch_Staging__c. Make it an exact duplicate of the account object, including as much validation of the original object as possible (with some standard objects this is difficult, so you might need an Apex trigger to accomplish this completely). Include an additional fields: either a lookup to store the real Account Id, or perhaps an External Id field to do the same. Best Practices for Improving Visualforce Performance. Visualforce was designed to provide developers with the ability to match the functionality, behavior, and performance of standard Salesforce pages.
If your users experience delays, unexpected behavior, or other issues specifically around Visualforce, there are several actions you can take to not only improve their experience, but to also make for improved coding. The following is a list of commonly encountered Visualforce performance issues and their possible solutions: View State Size. CloudForce4u. Selje Extending Web Apps. Visualforce Row Counter for Iteration Components. I have been working on a Visualforce page that displays a list of items from a collection and I want to display the current row number next to each item.
I found this post that describes a solution but I think there may be a bug in one of the components so here is proposed work around. I want to display a collection like this: It seems that there may be a bug in the way method works with the dataTable component. It works correctly with the following components. Repeat Component DataList Component. Enable Lightning and Install the SLDS Framework Step. Introduction In this project, you learn how to use the Salesforce Lightning Design System's (SLDS) CSS framework in Lightning Components.