Salesforce Interview Question – Part 15

141 : User Wants to set the starting day in Calendar as “Monday” instead of “Sunday”. How to get it done?
Ans : Change the user locale to “English ( United Kingdom ) ” in Personal information or User record.


142 : Why CSS is not working in PDF created by Visualforce ?
Ans : In Many cases, i have observed problems faced by my colleagues and complaining that CSS is not working when they try to render any Visualforce page as “PDF”. Same Question is asked many times in Interviews also. Basically there are two ways:

  1. Use “apex:stylesheet” tag to import external CSS file
  2. Wrap “Style” tag inside “Head” tag in Visualforce

143 : How to get Ip Address of User in Apex?
Ans :

String ipAddress = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');

True-Client-IP has the value when the request is coming via the caching integration.
X-Salesforce-SIP has the value if there is no caching integration (sandbox, developer edition orgs) or via the secure url.
Thanks to TechNrd for this tips.


144 : How to get total number of Child records in Lookup relationship?
Ans: As Rollup Summary field is only supported in Master detail, we cannot use it for Lookup. There are following two ways (If anyone has any other idea please comment).

  1. Inline Visualforce page
  2. Trigger on Child Object, which will update field in Parent record if child record is inserted, deleted or undeleted.

145 : System admin has created a Visualforce for Account. In future he created few more new Fields. How could System admin can code Visualforce so that in future if any new field is added or existing field deleted. It should reflect in Visualforce without changing anycode?
Ans : It can be done with help of Field Sets. Please read this article.


146 : Once you convert lead, Few fields on lead should be reset so that sensitive information should not be queried using SOQL. How to get this done?
Ans : Once lead is converted, its READ ONLY. we cannot update it using Apex or Trigger. However we can use “Before Update” trigger on lead and check for fiels “IsConverted“. If its true means lead is going to be converted so reset all fields in that case.


147 : How to convert carriage returns in Textarea to Line Breaks in Visualforce?
Ans : We can use “<apex:outputField>” instead of “<apex:outputText>”. It will maintain formatting automatically.


148 : How to handle comma within field while uploading using DataLoader ?
Ans : Data Loader cannot handle this implicitly because there is no logical path to follow. In case your Data Loader CSV file for import will contain commas for any of the field content, you will have to enclose the contents within double quotation marks ” “. Data Loader will be able to handle this.

For example :

Column_1__c,Column_2__c,Column_3__c
Shiva,"Jitendra, Minal",Soft

If you are creating the import CSV in Excel, the quotation marks will be inserted automatically by Excel whenever a comma is detected in any cell – Saving the CSV in Excel and opening the same in Notepad reveals the enclosing quotation marks for cells containing commas.


149 : In Master Detail Relationship :
OWD for Parent is public Read Only.
If User has – Create, Edit Permission on Master as well as Detail Object.

While creating record for detail object he selects parent record which is not created by him. What will happen in this case ?

Ans : He will get an error, because in order to add child record user must have edit permission in parent master record.


150 : Difference in “Export” and “Export All” in Data Loader in Salesforce?
Ans :
Export : It is used to export the Salesforce Data(excluding recycle bin’s data) into your local system.

Export All :  It is used to export the Salesforce Data(including recycle bin’s data) into your local system.

Related posts