Monday, 27 October 2014

salesforce.com interview questions

161 : Sometimes while deleting record it gives error “Object cannot be Deleted”. What is the reason for this kind of error ?
Ans :
This is generic error message prompted by Salesforce many times, which is not well informative. To get informative message, we can try to delete same record in “Developer Console”. In Developer Console Debug log, we will get exact error message.
Example : Lets say there is one record which is parent of more than 2000 records and grand parent of 5000 records. In such scenario from developer console it gives error something like “record cannot be deleted because it has many associated objects” However in User Interface, it will just display that “Object cannot be deleted.

162 : Why are Visualforce pages served from a different domain?
Ans :
If we see carefully, all our Visualforce pages are served like “c.YOURSERVER.visual.force.com/apex/YOURPAGENAME” ,
And because of this most of time we run into Same-Origin Policy error in Javascripyt if we try to access parent page from Iframe. Following reason is explained by one of the evangelist of Salesforce:
“The move to separate domains has one very specific purpose: leverage the browser security model (same domain policy) to protect our customers and the salesforce.com service from cross site scripting and cross site request forgery attacks.
Moving to the serving pages from separate domains is a critical component of our ongoing commitment to insure the highest level of security and availability for everyone.
In the world where everything is served from the same domain any custom page that you visit had full access to any other page in your org and also any page served from salesforce.com itself. This included potentially malicious code that was installed as part of a force.com package.”

163 : In below code snippet , What is your observation and what is going wrong ?
1trigger TestBeforeDelete on Lead (before Delete) {
2 
3        for(Lead l : Trigger.Old)
4        {
5            l.addError('error');
6        }
7 
8        String msgBody = 'Test Email';
9        String Subject = 'Test from Cogni Force on Lead';
10        Messaging.SingleEmailMessage mail = newMessaging.SingleEmailMessage();
11        String[] toAddresses = new String[] {'abc@gmail.com'};
12        mail.setToAddresses(toAddresses);
13        mail.setReplyTo('abc@gmail.com');
14        mail.setSenderDisplayName('Cogniforce Test Simulator');
15        mail.setSubject(Subject);
16        mail.setPlainTextBody(msgBody);
17        mail.setHTMLBody(msgBody);
18        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
19}
Ans :
It will not send any email. Because “adderror” prevents all transactions from committing including emails.

164. Can we mass delete reports using Apex (Anonymous Apex) ?
Ans :
Salesforce has not exposed any API for Reports. So best way is :
  1. Move all reports needs to delete in new folder.
  2. Inform everyone that reports will be deleted after some time may be 30 days.
  3. Import your reports folder in Eclipse including all reports to be deleted and then delete the the reports folder in eclipse. It will delete all the reports at once.

165. 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 ?

Ans :
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 ?
1//format the datetime to make it Dynamic Soql ready
2String formatedDt = cutOffDateTime.format('yyyy-MM-dd'T'HH:mm:ss'Z'');
3String 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.

166. How you can use Datetime field as a criteria in SOQL Query ?
Ans : 

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

167. 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 ?
Ans :
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.

168. How do you import Converted Lead into Salesforce from Legacy System ?
Ans :
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.

169. 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.
Ans :
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.

170. In Partner Community, external user is having appropriate OWD and Profile Settings for Opportunity or consider any other Object. However they are getting insufficient privilege access, what might be cause of this error ?
Ans :
  • Check External User has all FLS for fields used in Report Filters
  • After Winter 14, If Community enabled, there will be two kind of OWD. External and Internal means what information should be visible to internal and external users. Also , there will be new setting named “Standard Report Visibility“. If it is checked user can see reports based on Standard report type even though they don’t have proper OWD and may expose sensitive information about internal user to external users (for example : Internal users role). If external user is getting an error whole running the report this setting may be one of the cause.

1 comment:

  1. I'm preparing for a nodejs interview but could not find a good article. However, your article has helped me a lot and i also found a content of nodejs interview questions which has good set of questions, probably this can help the readers in clearing interviews too.

    ReplyDelete