Tuesday, June 27, 2017

Fields:


1. What is difference between standard objects and custom objects?
Standard are objects are predefined by Salesforce like Accounts, Case, Contact etc. Custom object are created by developers based upon application requirements.

2. What are system modifiable fields. Whether these fields can be modified?
Fields like createdby, createddate, modifiedby, modifieddate are system modifiable fields. These fields cann’t be modified. If you want to upload historical data and want to specify values for these fields, then you need to contact salesforce and they will make these fields available for certain duration.
Remember you can specify these fields while doing insert only. You cannot update these fields after insertion. System modifiable fields are available through API’s only not on UI. As a best practice always enable these fields only for initial data migration.

3. True or False: The Created Date can be updated for a record via the API as long as the Modifiable System Fields id turned on.
False. These fields are available for insert and cannot be updated once uploaded.

4. Does salesforce stores the deleted objects and fields?
Yes, salesforce stores the deleted objects and fields for 15 days in recycle bin. You can restore or undelete them from recycle bin.

5. What are external Ids? Does external ids are unique in salesforce?
A field of type external id is a unique id of records from another system. The performance of reports and SOQL is better for fields defined as external ids. Fields of type number, text and email can be set as external id. Each object can have upto three external ids.
External ids are not unique in salesforce. You need select unique and external id checkboxes while creating fields to make external ids unique.
Advantages of External Id:

-Increase report and API SOQL performance
-Used with upsert to easily integrate apps with other systems


6. What all data type can be used as controlling fields?
Picklist and checkbox. Standard picklist cannot be dependent picklist. Custom fields can be controlling as well as dependent fields.

7. What are encrypted fields?
A field defined as encrypted is not visible to users. Typical usage of encrypted field is for password. Only users with "View Encrypted Data" can view the encrypted fields. Encrypted fields are editable.

8. What is difference between 15 digit and 18 digit Record id?
In Salesforce, whenever user create any component (Object, field, tab etc...) or record then salesforce will generate an unique id with which user can identify the record or component.
After creating the record, in the URL user can see the id of the record which is of 15 digits length.
15 digit id- It is case sensitive and can be seen in user interface in URLs and Reports
18 digit Id- It is case insensitive. APIs and Apex (SOQL) always return 18 digit Id. Even through apex dataloader, we get 18 digit Id.

First 3 digit of record Id specifies the object to which record belongs. For example account records starts with “001” & contact record start with “003”.

9. What are different types of relationship in salesforce?
Basically there are 2 types of relationship, lookup and master detail.
Other relationships are:

  • Self-relationship- When object is related to itself. For example a case can be related to parent case.
  • Hierarchical relationship- When user has relationship with user. For example we can have manager field in user object which is related to user object only.
  • Many to many relationship- When an object is having master detail relationship with 2 different objects.  The intermediate object is called as junction object. An object is called junction object only if it has master detail relationship with 2 different objects.
10. Can a standard object become child in master detail relationship?
No. Standard objects always remain master.

11. What is difference between lookup and master details?
Look-upMaster
•Up to 25 allowed per object
•Parent is not a required field
•No impact on security and access
•No impact on deletion
•Can be multiple layers deep
• Lookup field is not required
•Up to 2 allowed per objects.
•Parent field on child is required
•Access to parent determines access to children.
•Deleting parent automatically deletes children(cascade delete)
•Can only be multiple layers deep, the number depends on whether master object is a standard or custom object
•Lookup field on page layout is required.

12. What are roll up summary fields?
Rollup-summary fields are supported in master detail relationship. The parent object can use roll-up summary field type to perform operations of sum, maximum, minimum, count among its children records.

13. What is junction object?
Junction object is an object which has master detail relationship with 2 different objects. Many-to-Many relationships are implemented using two master detail objects. One Junction object is used as the child of the objects between which many-to-many relationship needs to be established.

14. What is difference between self-relationship and hierarchical relationship?
Self-relationship is a lookup relationship to itself. For example a case record can be related to parent case record.
When there is self-relationship exist on user object, then it is called hierarchical relationship. For example, an employee's manager is also an employee.

15. Can we change already existing lookup relationship between 2 objects to master detail relationship?
System will allow changing relationship to master-detail only if all child records have value specified for parent as in master detail relationship, master is required.
If any of the child value doesn’t have parent value (means look up field is blank), then system will give validation error while changing the data type.
So if it is required to change relationship, them populate all blank values with some parent value and then change it to master detail.

16. Is it possible to change master-detail relationship to lookup relationship?
If the parent object doesn’t have Roll up Summary fields for the child object then we can convert.

17. Is it possible to create the Master – Detail Relationship field for the child object which is having existing records?
No, we cannot create directly. To create first we should create Look up relationship then populate the field value for all the records and then convert the look up relationship to master detail relationship.

18. What will happen if we undelete junction object and normal object from recycle bin?
Master – Detail Relationship data types will be converted to look up relationship data types.
If we undelete any object from recycle bin, then all master detail relationship will be changed to lookup relationship.

19. What will happen if we delete child record in case of look up relationship and master detail relationship?
In case of lookup relationship, we can delete parent object or child object. When parent object will be deleted, the value of lookup relationship field in all child records will become blank.
In case of master-detail relationship, if parent object contain roll up summary, then system will not allow you to delete child object.Also you cannot delete parent object in master detail relationship.

20. Is it possible to filter the records which are coming in look-up window when we click on lookup icon?
Yes, define filter criteria while defining the look up relationship.


Date field Formatting on VF page


If you have to format Date fields directly on VF page, then you can use below code snippets to achieve this.

<apex:page standardController="Opportunity">
    <!--display=10/25-->
    <apex:outputlabel value="Opportunity Close date (MM/dd):" />
    <apex:outputText value="{0,date,MM/dd}">
        <apex:param value="{!opportunity.CloseDate}"  />                              
    </apex:outputText>
    <br/>

    <!--display=October 25-->
    <apex:outputlabel value="Opportunity Close date (MMMM dd): " />
    <apex:outputText value="{0,date,MMMM dd}">
        <apex:param value="{!opportunity.CloseDate}"  />  
    </apex:outputText>
    <br/>
    
    <!--display= display=25 October-->
    <apex:outputlabel value="Opportunity Close date (dd MMMM): " />
    <apex:outputText value="{0,date,dd MMMM}">
        <apex:param value="{!opportunity.CloseDate}"  />                                   
    </apex:outputText>
    <br/>
    
    <!--  display=DD/MM-->
    <apex:outputlabel value="Opportunity Close date (DD/MM): " />
    {!Day(opportunity.CloseDate)}/{!Month(opportunity.CloseDate)}                           
</apex:page>


Output on VF Page:

08/06 
August 06 
06 August 
6/8

What is Name field in Salesforce?

Name field in Salesforce is the first field which gets created while creating a custom object.

The field type can be any one of the following

1. Text
2. Auto Number

The length of the text cannot be more than 80 characters.

The label of this field can be modified. But the field name/ API name cannot be changed.

Salesforce searchable field type

As Salesforce admin, sometimes we confuse when user come to us and ask, why my data is not searchable using Phone number or Email or a custom field with type equal to picklist .

Here is guide on searchable field type in using Salesforce Global search:

  • All custom auto-number fields and custom fields that are set as an external ID (You don't need to enter leading zeros.)
  • All custom fields type: email and phone
  • All custom fields type: text, text area, long text area, and rich text area
If you see FORMULA field is not searchable, it make sense because formula field is not stored in database.

How to have a star rating field on custom object in salesforce


Well, in that case, you'll have to create a separate field, most probably a Picklist Field would suit the need. You can create a Picklist Field say -
Label: RatingCode
Type: Picklist
Values:
1
2
3
4
5
And then create a another Formula Field on the same object. This is to represent the Rating "pictorially". That field would look like this -
Formula Return Type: Text
Label: StarRating
Type: Formula
?
1
2
3
4
5
6
7
8
9
Formula:
IF(
    ISBLANK(TEXT(RatingCode__c)),
    NULL,
    IMAGE(
        "/img/samples/stars_" + TEXT(RatingCode__c) + "00.gif",
        "Rating Level"
    )
)

Output:-


What is Roll Up summary field in Salesforce?

We can perform different types of calculations with your roll-up summary fields. You can count the number of detail records related to a master record, or calculate the sum, minimum value, or maximum value of a field in the detail records.

Note : Roll up summary field can only be defined on the master object.

While your formula fields calculate values using fields within a single record, roll-up summary fields calculate values from a set of related records, such as those in a related list.
The Roll up Summary field is basically of 4 types:
Count
Sum
Min
Max

What is junction object and how to create it?
Salesforce supports 2 kinds of relationships like Master Detail and Lookup. They are both one-to-many relationship, and they are both defined from the many-to-one side, that is from a child to a parent. They can be made one-to-one relationship by adding validation rules, or maybe triggers to enforce the one-to-one nature, i.e. only one child is allowed.

Junction objects are used to create many to many relationships between objects. If you take the Recruiting application example, you can see that a Position can be linked to many Candidates, and a Candidate can apply for different Positions. To create this data model you need a third object "Job Application" that links the 2.

So you'd create a lookup field for both Position and Candidate object on the "Job Application" object. This will establish many to many relationship between Position and Candidate via the "Job Application" object known as the junction object.

What is WhoId and WhatId in activities?
WhoID refers to people. Typically: contacts or leads. Example: LeadID, ContactID

WhatID refers to objects. Example: AccountID, OpportunityID

Which fields are automatically Indexed in Salesforce?

Only the following fields are automatically indexed in Salesforce:
  • Primary keys (Id, Name and Owner fields).
  • Foreign keys (lookup or master-detail relationship fields).
  • Audit dates (such as SystemModStamp).
  • Custom fields marked as an External ID or a unique field.
What are the examples of non-deterministic Force.com formula fields?
Before I mention some of the examples, let me give you an introduction to deterministic and non-deterministic formula fields. Formula fields whose value will be static are referred to as deterministic fields. Whereas, formula fields whose value will be changed dynamically or whose values will have to be calculated on the fly, they are referred to as non-deterministic formula fields. A classic example of that is a formula returning the current date and time.
Some examples of non-deterministic fields in Force.com are:
  • Lookup fields
  • Formula fields whose reference spans over other entities
  • Fields having dynamic date functions like:- TODAY() or NOW().

What is an external ID in Salesforce? Which all field data types can be used as external IDs?

An external ID is a custom field which can be used as a unique identifier in a record. External IDs are mainly used while importing records/ data. When importing records, one among the many fields in those records need to be marked as an external ID (unique identifier).
An important point to note is that only custom fields can be used as External IDs. The fields that can be marked as external IDs are: Text, Number, E-Mail and Auto-Number.

How many callouts to external service can be made in a single Apex transaction?

Governor limits will restrict a single Apex transaction to make a maximum of 100 callouts to an HTTP request or an API call.

Field Tracking




Out-of-the-box, Salesforce.com provide field tracking for up to 20 fields for standard and custom object. For custom object, you need to enable it by edit the object enable "Track Field History".








Once enabled, you will find a button "Set History Tracking" in "Custom Fields & Relationships" related list. For standard object, it will be there by default.

From "Set History Tracking" button, select fields you want to track up to 20 fields and yay... DONE!!

But, for Long Text Area field, it will just show who changed the field and when, that's all, no more information about what is the prior value and new value :( :(

Using Workflow and Field Update we can achieve this:
1. Create another Long Text Area to hold the history, in this sample, let's call it Response History to store history of Response (a long text area field).

2. Create a workflow with criteria ISNEW() || ISCHANGED( Response__c ).

3. Create an immediate workflow action with field update to update Response History field using this formula:

"Last Modified: " + LastModifiedBy.FirstName + ' ' + LastModifiedBy.LastName + ' ' + 
TEXT(DAY(DATEVALUE(LastModifiedDate))) + '/' + 
TEXT(MONTH(DATEVALUE(LastModifiedDate))) + '/' + 
TEXT(YEAR(DATEVALUE(LastModifiedDate))) + ' ' + 
CASE(LEFT(RIGHT(TEXT(LastModifiedDate),FIND(" ", TEXT(LastModifiedDate))-2),2), 
'00','08', 
'01','09', 
'02','10', 
'03','11', 
'04','12', 
'05','13', 
'06','14', 
'07','15', 
'08','16', 
'09','17', 
'10','18', 
'11','19', 
'12','20', 
'13','21', 
'14','22', 
'15','23', 
'16','00', 
'17','01', 
'18','00', 
'19','03', 
'20','04', 
'21','05', 
'22','06', 
'23','07','00')+ 
LEFT(RIGHT(TEXT(LastModifiedDate),FIND(" ", TEXT(LastModifiedDate))-4),6) 
+ BR() + "------" + BR() + 
PRIORVALUE( Response__c ) + BR() + 
Response_History__c

Please note this formula only work with user without daylight saving timezone, because it will manually parse the time from GMT to your timezone (in sample above to GMT+8), because as of now Salesforce.com do not have TIMEVALUE() function yet. Otherwise, you can only capture the date OR display it in GMT timezone.

Here is the screenshot of the result:

No comments:

Post a Comment