Posts

Showing posts from July, 2014

Polymorphic Relationships fields and their use in SOQL

Image
A polymorphic relationship is a relationship where the referenced objects can be one of several different object types. In Simpler words: Polymorphic key is a relationship field which can relate to more than one type of object as parent. Unlike Lookup and Master-detail relationships which are related to a single object, Polymorphic keys can refer to multiple objects. Where to find: As of date, Polymorphic keys cannot be created by developers. They are available for specific objects out of the box for e.g. WHOID and WHATID in Task and Event objects. SOQL Polymorphism:                                                                                                                    Before this feature we don’t have any way to get the content of the referenced object. For this first we collect the ID of a Name object and do a second query using information from that Name object to get to the content of the referenced object. But with SOQL polymorphism we can do al

Force.com Explorer

Image
This tool can be used for following tasks: 1) Browse Database schema, 2) Browse Custom objects and fields 3) Build and test SOQL queries. 4) It can also generate a simple schema report. Steps: 1) Force.com explorer is  built with  Adobe Flash Builder for Force.com . It's an AIR app, so you will need to d ownload  http://get.adobe.com/air/  on your system. 2) After downloading the above, download force.com explorer latest release from  http://developerforce.s3.amazonaws.com/media/forceexplorer/ForceExplorer.air 3) Install and run. 4) It will ask for your Username and password. PS: Don't forget to add "Access Token" with password. 5) You can specify the environment (sandbox, developer/production, pre-release, other) by clicking on Managed Accounts or Advanced options. 6) After successful login, you can find the below screen The Force.com Explorer software is currently in Beta and  The current version is  0.58A .  

Defer Sharing Calculation

Image
Defer sharing here means that Postponing the processing of sharing rules until after new users, rules and other contents have been being loaded. -> When we have to make a large number of group membership or sharing rule changes during a data loading project, we can use salesforce.com’s Deferred Sharing Calculation to make this maintenance more efficient and predictable. -> used to speed up data loading, by avoiding calculations on sharing rules. need to contact salesforce support, if this option is not enabled in your org. Steps to configure Defer Sharing Calculations: 1) Setup-> administer-> security controls-> defer sharing calculations To see the  Suspend ,   Resume , and   Recalculate   buttons on this page, users must also have the “Manage Sharing Calculation Deferral” permission. Creating a permission set allows you to easily assign this permission to all users who require access to these buttons. Using the Defer Sharing Calculation F

Ways to avoid Data Skew

Ways to avoid Account Data Skew: You should always strive to recognize and avoid account data skew situations that produce unwanted lock contention and diminished database concurrency. Correcting a data skew can be painful because you’re changing ownership, which in turn triggers sharing calculations. Here are some tips to help you avoid account data skews. PREVENT ACCOUNT DATA SKEW SITUATIONS THAT PRODUCE UNWANTED LOCK CONTENTION AND DIMINISHED DATABASE CONCURRENCY Design architecture to limit account objects to 10,000 children. Some possible methods include creating a pool of Accounts and assigning children in a round robin fashion or using Custom Settings for the current Account and the number of children. Consider a Public Read/Write sharing model in which the parent account stays locked, but sharing calculations don’t occur. If you have a skewed account, re-distribute child objects in chunks during down hours to reduce the impact of record-level lock contention.  Ba

Skew in Salesforce

Scenario in which parent record has more than 10,000 of records or if any user owns more than 10,000 records is known as “Data Skew”.  Salesforce does not recommend having more than 10,000 records own by any user or more than 10,000 Child for any parent. Types of Salesforce Data Skew Account Data Skew Certain Salesforce objects, such as accounts and opportunities, have special data relationships that maintain parent and child record access under private sharing models. If too many child records are associated with same parent object in one of these relationships, this imbalance causes something called “account data skew,” which in turn causes performance problems. If you are unfamiliar with account data skew, you can read more about it  here . Ownership Skew Similarly, when a large number of records with the same object type are owned by a single user, this imbalance causes something called “ownership skew.” Ownership skew also causes performance problems, which ca

Access picklist values in Apex.

Have you ever worked on the requirement to get all the values of picklist field in apex? If no, you may have to work on it in near future. For example in account object , grade__c is a picklist field with values average, good, excellent. So for implementing such condtion we are going to use dynamic apex. What Dynamic apex does here is that it allows to query a field or sObject, and  describe it's attributes. 1) First step is to create a controller with   getDescribe()  method which will enable us to obtain information on the  grade __c   field Schema.DescribeFieldResult fieldResult = account.grade__c.getDescribe(); As  grade__c  is a picklist field of which we need to  retrieve  all values: List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); If we want to get picklist values in list do the following: List<String> lstPickvals=new List<String>();   for (Schema.PicklistEntry a : ple )     {       lstPickvals.add(a.ge

Annotations used in Salesforce

Annotations: Apex  supports the following annotations: @Deprecated @Future @IsTest @ReadOnly @RemoteAction Apex REST  annotations: @RestResource @HttpDelete @HttpGet @HttpPatch @HttpPost @HttpPut @Deprecated: Use the  deprecated  annotation to identify methods, classes, exceptions, enums, interfaces, or variables that can no longer be referenced in subsequent releases of the  managed package  in which they reside. This is useful when you are refactoring code in managed packages as the requirements evolve. New subscribers cannot see the deprecated elements, while the elements continue to function for existing subscribers and  API  integrations. Note the following rules when deprecating  Apex  identifiers: Unmanaged packages cannot contain code that uses the  deprecated  keyword. When an  Apex  item is deprecated, all  global  access modifiers that reference the deprecated identifier must also be deprecated. Any global method that uses the depr

Federated Authentication using SAML

Image
F ederated authentication uses SAML, an industry standard for secure integrations. Investing in SAML with Salesforce.com can be leveraged with other products or services. If you use SAML, you don't have to expose an internal server to the Internet: the secure integration is done using the browser. In addition, Salesforce.com never handles any passwords used by your organization. When an HTTP request arrives at Salesforce, if there is no valid session ID supplied (or the request is for a login page), Salesforce first examines the requested domain. If the requested domain is a  My Domain  (i.e. of the form  https://mycompany.my.salesforce.com/ ), then we look up the associated org and check whether SAML (or, from Winter '13, an  Authentication Provider ) is configured for single sign-on. If SAML is configured, then the browser is redirected to the relevant identity provider (IdP), the user is authenticated there, and the browser POSTs a signed SAML assertion (XML document)

Delegated Authentication in Salesforce

Image
Prerequisite:   Contact  salesforce.com   to enable delegated authentication single sign-on for your organization. It works well if you have an existing intranet site where your customers are already logging into.   -  With delegated Salesforce will call a web service that you built that will return a simple yes/no on whether the user should be authenticated.   - With an intranet site the flow will usually be:      1) User logs into intranet site just like they always have     2) User clicks on a Salesforce link     3) The intranet site will post a page to Salesforce with the user id and password/token to be logged on with.     4) Salesforce sees that this user is using delegated authentication by a profile or permission set setting.       5) Salesforce calls the web service to authenticate, which usually is hosted on the intranet site’s servers     6) The web service returns yes to the authentication request and Salesforce allows the user access.   - Delegated Authenticat