You may be wondering that there are tons of articles available for upsert operation and what is need of one more blog post. I wanted to note everything important about upsert operations using datalaoder and Apex with identified gotchas at single place, and that’s why its here 🙂 .
External ID is field in Salesforce to say that this field is primary key in external Database which can be used to identify that external record exists in Salesforce or not ? There are many benefits of external key like :
It can be used to identify if record exists or not and record automatically inserted or updated using upsert operation
Upsert operation is supported by Dataloader, Apex and API
Any field marked as external id is indexed and can be used in SOQL or report filter
You can create Parent child record in single statement in Apex
Using Upsert operation to create/update child record and relate to existing parent record with help of External Id
Lets assume that you have list of contacts and Account in external SQL Server database and you want to import those Account and contact weekly. It is possible that you have already imported contacts previously so don’t want to duplicate records if already created in Salesforce. To solve this problem we can use external Id on Contact and use upsert operation on dataloader. Let’s assume external Id field on Contact is “SQL_Server__Id__c” (I am assuming that Account records in Salesforce also have external Id and records are already imported. Same below steps can be used to import Account record as well).
During project development life cycle it is very essential to backup your code and Configurations daily. However sometimes developers forgot to commit changes in Git, may be because of workload. It may create an issue if someone wants to check back history of code for that duration, there will be no use of having code repository in place if it cant help us to get out of problem.
In this article, I will move one step further and explain how to setup automated script which will run on your System startup and commit backup of your Salesforce organization into local Git repository without any manual interference.
You would like to go through this useful cheat sheet for “Query and Search” optimization, few of this is discussed in this post as FAQ.
171 : How Standard Fields and Custom Fields related information is saved inside Salesforce Database? Is every Standard and Custom Object is created as a different Database table? Ans :
Salesforce is using Multi-tenant architecture, means many organizations (Tenants) are using same infrastructure. Salesforce Database saves Metadata Information in hundreds of table. Run time engine then generates organization specific query to get information about their organizations and Data from common table as shown in below diagram. Below Database tables are partitioned by Organization ID and generates virtual table specific to Org.
172 : As a Developer, how can you optimize SQL query to fetch data from Salesforce Database? Ans :
As Salesforce doesn’t save data in traditional way. Data of all tenants are in common table, so traditional Query optimization query and technique will not work in this case, so there is no such tool available to optimize final generated SQL. We only have option to create SOQL which is optimized by custom inbuilt Force.com Query Optimizer.
In Summer14, Salesforce released Query Plan Tool to analyze how query is performing. With help of this tool, we can get an idea how we can change our query to perform better.
173 : When records are created in Salesforce, How it is queued for Indexing? Ans :
If newly created records are equal to or less than 9000, then it will be indexed in 1 to 3 minutes. However if records are more than 9000, then servers perform bulk indexing at a lower priority, so processing might take longer.
In Customizable Forecast, we can add the Quota for user by navigating to User Page and going to Quota related list However in Collaborative Forecasting aka Forecast 3 the only way is using Data Loader.
1. Log-in to the Data Loader and use the Insert function.
2. Click “Show all Salesforce objects and select “Forecasting Quota (ForecastingQuota)”. Note: Only Data Loader version 25 and above can be used for importing Quotas in Collaborative Forecasting
3. Select the import csv file and click Next (click OK in the pop-up that shows the number of records detected in the file).
Note: The import csv file should contain the following columns:
Currency ISO Code
Quota Month (Start Date, In Date Format , 10/1/2013 – 1 Oct 2013)
Set Environment variable “ANT_HOME“. The path should be of parent folder of “bin”. Also add the “bin” folder to your path.
Check whether ANT is installed or not properly by running command “ant -version“. It might be possible that you receive message something like unable to find tools.jar. You can copy this jar from “JDK_HOME/lib/tools.jar” to “JRE/lib” folder.
61. How to round the double to two decimal places in Apex?
Decimal d = 100/3;
Double ans = d.setScale(2) ;
62.In Profile settings, what is difference between “Modify All Data” and “Modify All” ?
Ans: Modify All Data : Create, edit, and delete all organization data, regardless of sharing settings. Modify All : Give Read, Add, Delete permission to selected Object, Create permission is not included in Modify All permission.
51. Explain Permission sets released in Winter 12. Ans :
A permission set is a collection of settings and permissions that give users access to various tools and functions. The settings and permissions in permission sets are also found in profiles, but permission sets extend users’ functional access without changing their profiles. For example, to give users access to a custom object, create a permission set, enable the required permissions for the object, and assign the permission set to the users. You never have to change profiles, or create a profile for a single use case. While users can have only one profile, they can have multiple permission sets.
Email services are automated processes that use Apex classes to process the contents, headers, and attachments of inbound email.
You can associate each email service with one or more Salesforce-generated email addresses to which users can send messages for processing.
The general template to create the apex class for the email services is:
This morning when i started the eclipse and tried to refresh the contents from salesforce server, i got an error something like “com.salesforce. ide.api.metadata.types. Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor“.
I started searching for the solution and found below solution on salesforce community.
Note – I was using Windows 7 operating system.
Use JRE v6 update 27 – 64bit (downgraded from JRE 7)
Use JDK v6 update 27 – 64 bit (downgraded from JDK 7)