Thursday 7 December 2017

SFDC Interview Questions - Part 8

29)  How to display the formatted number / date in Visualforce ? Which component should be used?

Ans : Use component “<apex:outputText>”.

30)  You want to display the Encrypted field on Visualforce and you are using component  apex:outputText. Will it work for Encrypted fields?

Ans : 
1)      Encrypted custom fields that are embedded in the <apex:outputText> component display in clear text.
2)       The <apex:outputText> component doesn’t respect the View Encrypted Data permission for users.
3)      To prevent showing sensitive information to unauthorized users, use the <apex:outputField> tag instead.


31) Explain difference in COUNT() and COUNT(fieldname) in SOQL.
Ans :
COUNT()
·         COUNT() must be the only element in the SELECT list.
·         You can use COUNT() with a LIMIT clause.
·         You can’t use COUNT() with an ORDER BY clause. Use COUNT(fieldName) instead.
·         You can’t use COUNT() with a GROUP BY clause for API version 19.0 and later. Use COUNT(fieldName) instead.
COUNT(fieldName)
·         You can use COUNT(fieldName) with an ORDER BY clause.
·         You can use COUNT(fieldName) with a GROUP BY clause for API version 19.0 and later.

32)  How to write the “Where” clause in SOQL when GroupBy is used ?

Ans : We cannot use the “Where” clause with GroupBy instead we will need to use the “Having Clause“.
           Eg: SELECT COUNT(Id) , Name FROM Opportunity GROUP BY Name  Having COUNT(Id) > 1 AND Name like '%ABC%'

33) How to force lead assignment rule via Apex while updating or adding the Lead?

Ans : To enforce Assignment Rules in Apex you will need to perform following steps:
1.    Instantiate the “Database.DMLOptions” class.
2.    Set the “useDefaultRule” property of “assignmentRuleHeader” to True.
3.    Finally call a native method on your Lead called “setOptions”, with the Database.DMLOptions instance as the argument.

34) How to implement the pagination in SOQL ?
Ans:
  
1)      In spring 12, Salesforce has come up with ability of SOQL to get records from position “X”   instead of position “1” every time to help creating pagination feature.
2)      With “OFFSET”   clause, you can now paginate through your result set directly in SOQL.

35)  Access custom controller-defined enum in custom component ?

Ans :
We cannot reference the enum directly since the enum itself is not visible to the page and you can’t make it a property.

36)  What is dynamic binding in salesforce?

Ans:

          Dynamic Visualforce bindings are a way of writing generic Visualforce pages that display information about records without necessarily knowing which fields to show.

37) Consider total 90k records present in Salesforce and you have used the count() method of soql. What will be output of it?
Ans :    
1)      It will throw an error something like “Too many query rows: 50001”, as the record limit in SOQL is 50,000.
2)      Although the count() returns only one row however it processes each record and thus hit the allowed governor limit.

38) How can you determine that email is actually sent or not from the salesforce?


Ans:  
1)      There is an Email log that you could use. It’s available in the setup menu under Monitoring.
2)      It’s only for the past 30 days and you would have to manually check it.


39) In salesforce which fields are indexed automatically?

Ans :
 The following fields are indexed by default:
·         primary keys (Id, Name and Owner fields),
·         foreign keys (lookup or master-detail relationship fields),
·         audit dates (such as LastModifiedDate),
·         Custom fields marked as External ID or Unique.

40 ) Give any scenario when you cannot change the currency field type to numeric type.

Ans : When the field is used either in Apex class or trigger.

41)  What is a Recursive Trigger?
Ans:  The trigger when trying to create a new record as part of its processing logic fires another trigger.

42)  How will you overcome recursive trigger?
Ans:  By taking a static Boolean variable in an apex class we overcome recursive triggers.










                                                                                        


No comments:

Post a Comment

Batch Apex

1. What are transaction limits in apex? Total number of SOQL queries issued1 - 100 Total number of records retrieved by SOQL queries - 50...