Tuesday, January 28, 2014

How to setup Field Level Security (FLS) for Person Account Fields. OR Why I am not able to find list of Person Account fields in Field Level Security (FLS) settings when navigated to fields on Account Object.

How to setup Field Level Security (FLS) for Person Account Fields.
OR

Why I am not able to find list of Person Account fields in Field Level Security (FLS) settings when navigated to fields on Account Object.

Field Level Security (FLS) of Person Account fields ar controlled by Contact Fields. So, if you want to setup FLS of Person Account Fields navigate to fields of Contact and it will be reflected on Person Account

How do you import Converted Lead into Salesforce from Legacy System

How do you import Converted Lead into Salesforce from Legacy System

Fields we need for importing converted leads are “ISCONVERTED” , “CONVERTEDCONTACTID” , “CONVERTEDOPPORTUNITYID” and “CONVERTEDACCOUNTID“.
Step 1 : As above fields are not editable, we have to contact Salesforce Support to enable Audit fields. Enabling Audit fields means we can edit few Readonly fields like created date and above lead fields.
Step 2 : Import Account, Contact and Opportunity from Legacy system to Salesforce.
Step 3 : If you imported account, contact and opportunity in Step 2, Salesforce automatically generates Unique ID. We need that unique Id to insert Converted Lead. So Export Account, Contact and Opportunity, which is inserted in Step 2 from legacy System.
Step 4 : Create CSV File with All lead information with ISCONVERTED=TRUE and CONVERTEDCONTACTID, CONVERTEDOPPORTUNITYID, CONVERTEDACCOUNTID. CONVERTEDCONTACTID, CONVERTEDOPPORTUNITYID and CONVERTEDACCOUNTID should correspond to Ids generated by Salesforce for Contact, Opportunity and Account which will be related to converted lead.
Step 5 : Once CSV is properly created with all required Data, Insert it using DataLoader.

Note : We cannot convert existing lead using this process. Leads must be inserted with these four fields. If you try to update lead it will not give you option to edit above fields 

After Data Export using DataLoader, Some time it appears that data is on New Line (Carriage Return) when we open CSV file in Microsoft Excel. For example , Address Data separated on different lines. How can we override this problem

After Data Export using DataLoader, Some time it appears that data is on New Line (Carriage Return) when we open CSV file in Microsoft Excel. For example , Address Data separated on different lines. How can we override this problem

Excel does all sorts of “useful” things when it opens a CSV file. It will re-format dates, strip leading zeros, corrupt record IDs (if you have them in your report), and as explained it will also break line. Best way as per my experience till date is, Upload document to Google Drive. Export document back from Google drive as Excel.

Please post comment in this article if you know any other working way.
  

How you can use Datetime field as a criteria in SOQL Query

How you can use Datetime field as a criteria in SOQL Query

We cannot use Datetime as condition in Where Clause in between single Quotes.
You can do something like this ,

WHERE CreatedDate > 2005-10-08T00:00:00Z
Or, you can also use Date Literals like

WHERE CreatedDate > YESTERDAY
For more information on date formats and more literal values, check this URL.
Sample:
soql += ' and Name LIKE \''+String.escapeSingleQuotes(key1)+'%\''; - not required single quote like this.
  

While creating Dynamic SOQL, which involves Datetime gives ” no viable alternative at character ‘’ ” error. OR value of filter criterion for field ‘CreatedDate’ must be of type dateTime and should not be enclosed in quotes OR How to use Datetime in Dynamic SOQL Query in Salesforce

While creating Dynamic SOQL, which involves Datetime gives ” no viable alternative at character ‘<EOF>’ ” error.
OR
value of filter criterion for field ‘CreatedDate’ must be of type dateTime and should not be enclosed in quotes
OR
How to use Datetime in Dynamic SOQL Query in Salesforce

This error is because of wrong construction of Dynamic Query with Datetime. following code snippet will give idea on how to construct dynamic query for Datetime ?
//format the datetime to make it Dynamic Soql ready
String formatedDt = cutOffDateTime.format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
String sql = 'SELECT  a.Id  FROM  Agents_Answer__c a    WHERE  a.Agents_Test_Result__r.Agent_Name__r.IsActive__c = false AND  LastModifiedDate < '+ formatedDt ;

Where, “cutOffDateTime” is variable of datetime type.