Wednesday 27 August 2014

Interview questions

How to convert Set to List in Salesforce?

 Sample Code:

        Set<Integer> i = new Set<Integer>();
        i.add(1);
        i.add(2);
        i.add(3);
       
 
        List<Integer> s = new List<Integer>();
        s.addAll(i);
------------------------------------------------------------------------------------------------------------------------------------------------------------Spring 14 new feature
Create a Report with Chart . If you don’t to how to do that please go through my article Embedding Charts Anywhere
  1. Copy the report ID, you can get a report’s ID from the report URL in Salesforce, or request it through the API.
  2. Now create a Visualforce page and use Visualforce tag <analytics:reportChart> with attributereportID
Code:-
 <apex:page >
<analytics:reportChart reportId=”00Ox0000000i8gv” size=”small”></analytics:reportChart>
</apex:page>
-----------------------------------------------------------------------------------------------------------------------------
How to get the Ip Address of User using Apex in Salesforce?
String ipAddress = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');

'True-Client-IP' - when the request is coming via the caching integration.

'X-Salesforce-SIP' - when the request is not via caching integration (sandbox, developer edition orgs) or via the secure url.
How to allow DML operations in apex:component in Salesforce?
In order to allow DML operations in apex:component, allowDML attribute should be made true.

Sample Code:

<apex:component controller="TearPagesController" allowDML="true">
Purge:permanently deletes records from recyclebin;
Purge in Workbench.developerforce.com

Purge option in Workbench.developerforce.com is used to delete the recycle bin data from you Salesforce.com organization.

Query to fetch Role name and Profile Name from User Object

SOQL:

SELECT UserRole.Name, Profile.Name FROM User
Query to fetch Role name and Profile Name of record Owner
SOQL:

SELECT Name, Owner.Name, Owner.UserRole.Name, Owner.Profile.Name FROM Account
Unable to fetch reference records in Workbench - Workaround
By default, in Workbench "Allows SOQL Parent Relationship Queries" will be unchecked. So, check the "Allows SOQL Parent Relationship Queries" check box to  fetch reference records in Workbench.
How to fetch all record types in Salesforce?
SOQL:

SELECT Id, Name, DeveloperName, SobjectType FROM RecordType
Validation Rule and Trigger is not working during Lead conversion - Solution
To fire Validation Rule and Trigger during Lead conversion, follow the below steps

1. Go to Setup --> Build --> Customize --> Leads --> Settings and check "Enforce Validation and Triggers from Lead Convert" check box
How to get record id from standard controller using Apex in Salesforce?
Sample Code:

Visualforce page:


<apex:page standardcontroller="account" extensions="Sample">
{!Aid}
</apex:page>


Apex Controller:

public class Sample { 

    public Id Aid {get;set;}
   
 
    public Sample(ApexPages.StandardController controller) {
        Account acc = new Account();
        Aid = controller.getId();
    }        
 
}
How to get current User Id using Apex in Salesforce?
UserInfo.getUserId() - returns the current User Id

Sample Code:

User Usr = new User();
Usr = [SELECT Phone, Id FROM User WHERE Id = : UserInfo.getUserId()];

Complete Salesforce CPQ training Free videos

Salesforcestart:: We are excited to announce that our YouTube channel, Salesforcestart, is your one-stop-shop for all things Salesforce CPQ!...