Wednesday, June 28, 2017

Data loader and import wizard in salesforce:

Import Wizard:
  • For simple imports of up to 50000 records.
  • It supports all custom objects and only few standard objects like Account, Contact, Leads, Solution.
  • It supports schedule export.
  • Delete operation is not available.
  • We cannot export data.
  • It doesn’t require installation.
  • While importing, duplicates can be ignored.
Data Loader:

  • For complex imports of any size more than 50000 records.
  • It supports all standard and custom objects.
  • It doesn’t support schedule export.
  • Delete operation is available.
  • We can export data of all custom & standard objects, and can import all custom & standard objects except User standard object.
  • It requires installation.
  • While importing, duplicates cannot be ignored.
Data Loader  is a tool or Application used in salesforce to import and export bulk data. ThroughApex Data Loader we are able to Update, Insert, Delete, Upsert, Export and Export All. Each operation will be different from each other.
  • Insert – insertion of new records
  • Update – Updating existed  records.
  • Upsert – Update and Insertion of records
  • Delete – Deletion of records.
  • Export – Extraction of all records.
  • Export All – It extracts all records from salesforce including Recycle Bin records.

Can We Bypass The Required Fields In Data Loader?

Ans: Inserting the records through Data loader Required fields cannot be skipped. If you have Required fields in your object make sure you have values in the CSV for those fields as well. There is no setting to by bass the required field check. although you can turn off the validation rules simply uncheck the Active check box.

What Are The Required Fields When Inserting Users Through Data Loader?

Ans:
  • Alias
  • Username
  • Email
  • First Name
  • Last Name
  • Locale (LOCALESIDKEY)
  • Language (LANGUAGELOCALEKEY)
  • Email Encoding (EMAILENCODINGKEY)
  • Time Zone (TIMEZONESIDKEY)
  • Currency (CURRENCYISOCODE)
  • ProfileId (not profile name but rather the 15-character ID from the URL of the profile in the UI) 

How to differentiate commas within field while uploading using Data Loader ?

Ans: Data Loader cannot differentiate this implicitly because there is no logical path to follow. In this case 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 find this.
Hard Delete Not Working In Apex Data Loader?

Ans: Check your Profile permissions  “Bulk API Hard Delete” check box should be enable  for permanently deleting the records using Apex Data Loader. Using Hard Delete operation, we can delete existing records from our Salesforce organization permanently. Deleted records will not be available in Recycle Bin.
Bulk_API_Hard_Delete

How To Import MultiSelect Picklist Values Through Data Loader?

Ans:  By using apex data loader inserting or updating multi select pick list fields through the Apex Data Loader, multiple values for the mulit picklist field are separated by a semi-colon “;”.
How To Import Different Languages?
For example: for a multi select field “Products”, containing the values Product1,Product2 and Product5, the .csv spreadsheet column for inserting or updating the data would be entered as “Product1;Product2;Product5“.

How To Import Different Languages Data Into Salesforce?

Import Different Languages Data Into Salesforce

Ans: Follow the below simple steps to import different languages data using Apex Data loader.
  1. Open the .xls file that displays the other language characters correctly and which was prepared for import.
  2. Click File –> Save As. In “Save as type”, kindly select Unicode Text (*.txt).
  3. Click “Save” button.
  4. Open the .txt file in Notepad.
  5. In Notepad, click File –> Save As, In“File name”, change the file’s extension from .txt to .csv. “Save as type”, select “All Files”, In “Encoding”, select “UTF-8”, Click “Save” button.
  6. Import the .csv file.

How To Change Lead Owner For Bulk Of 


Records?

Ans: Using the data loader to update lead owner on bulk of records with in 1 min. follow the below simple steps.
  1. First Export the Leads to which owner has to be changed.
  2. While exporting select Lead ID(Id) and Owner ID(ownerId) without fail.
  3. Modify the exported file ownerId with the user Id of the user to which Lead has to be assigned.
  4. Now update the Leads. that’s it.
    Data loader Login Error "Parser Was Expecting Element" ?
    data_loader_error

    Ans: While login to the data loader it says  "Parser was expecting element". Go to data loader settings then Follow the below simple steps to fix it.

    Also Read: How To Start Loading Data From 101 Row Of The CSV File In Data Loader?
    1. Make sure "API Enabled" permission is checked on the Profile.
    2. Check whether you have given the proxy correctly.
    3. Check whether you have given the port number correctly.
    4. Check whether you have given the correct url(for Production - https://login.salesforce.com and for Sandbox - https://test.salesforce.com).


What Are The Salesforce Editions Supports Apex Data Loader?

Ans:  The Data Loader requires the use of the Force.com API. If your Salesforce edition allows the use of the API ,you can use apex dataloader.  Now, ProfessionalEnterprise and Unlimited edition supportsdata loader

How To Start Loading Data From 101 Row Of The CSV File In Data Loader?

Ans: Open your data loader then Menu section Go to Settings–>scroll down  and Set “Start at Row” field to start the process from the 101 row number from the CSV file.
You can see the below screen.
 

How Can We Bypass Workflow Rules When Using The Data Loader?

Ans: We don’t have any option to skip workflow rules,Validation rules and Triggers from data loader.But we can deactivate the workflow rules while loading data through data loader. But it’s not a good practice,why because that the workflow can be deactivated in the app before using the Data Loader, but users can be creating/editing records during this process which should not be interrupted

How To Skip Triggers And Validation Rules From Apex Data Loader?

Ans: We can skip the trigger and Validations rules while loading the data through data loader Manually deactivating and activating trigger and Validations. But We are having large number of triggers andvalidation rules in our salesforce production org. We also do manual dataloader operation frequently.It is time consuming and on top of that it also affects live production users. It’s not a good practice
 It would be really good if dataloader can provide facility to skip triggers and validation rules ( e.g. to provide checkbox to skip ) while running dataloader operation.
What is an External Id in data loader in salesforce?
Suppose we have account table in Salesforce and account table outside of the Salesforce (ex: .csv file, sql database). In Salesforce all the records can be identified with record id and outside of the Salesforce we can't recognize records with Salesforce id that is the reason to compare outside table and salesforce table in Salesforce for one of the field we have to enable external ID (we can enable external id for text, number, auto number and email). If we enable external id we can compare that particular column with the column which is available in external table. While comparing if the both column values are same then it will update otherwise it will insert.
                                                                OR
          An external ID field is simply a field which is a unique identifier for your record, other than the Salesforce Id, usually coming from an external system. For example, if you are importing accounts, you may have a field called 'ERP Account Number' which is the identifier for your Accounts inside your ERP system.

How To Assign Permission Set For Multiple Users Through Data Loader? 

Ans:   To assign Permission Set for multiple Users using apex data loader, follow the below steps,

  1.  Create a .CSV file with User id and Permission set id to be assigned.
  2. Login into Apex Data loader.
  3.  Click “Insert” button.
  4.  Select “Permission Set Assignment” as object and browse the .csv file created in step1
How To Use Upsert Operation With Apex Data Loader?
Upsert_operation_in_salesforce

Ans: Upsert opeation makes use of the sObject record's primary key(Salesforce.com Record Id) or the external ID, if specified to determine whether new records should be created or else we have to update the existing records.

 What is the difference between update and upsert?

Key points to remember while upsert operation. 
  • If the key is not matched, then a new record is created.
  • If the key is matched once, then the existing record is updated.
  • If the key is matched multiple times, then an error is generated and the object record is neither inserted nor updated.
What are the difference between DATA IMPORT WIZARD PILOT and IMPORT WIZARD?

(or) WHAT IS A DIFFERENCE BETWEEN DATA LOADER AND IMPORT WIZARD IN SALESFORCE?

Answer:  
DIFFERENCE_BETWEEN_DATA_LOADER_AND_IMPORT_WIZARD

The Data Import Wizard provides a unified interface that lets you import a number of standard Salesforce objects, including accounts, contacts, leads, and solutions and custom objects. It Is designed for less-technical users and smaller, simple imports of up to 50,000 records.
         The Data Import Wizard is currently available through a pilot program. It is automatically enabled for all Developer Edition organizations. To enable the wizard for Enterprise and Unlimited Edition organizations, contact salesforce.com.
.SDL
In dataloader settings we should enable 'insert null values' checkbox otherwise we can't insert null values.
10,000 records and minimum 1 record.
2,000 records.
.CSV (Comma Separated Values)
  1. Insert (Inserting brand new records, no need of ID)
  2. Update (Updating the existing records based on the record ID)
  3. Upsert (To Upsert we should have one external ID field on the object, based on the external id field if the value already exists it will update, if doesn't exist then it will insert)
  4. Delete (Delete the records based on the id provided, to delete we need only id, deleted records can be found in recycle bin)
  5. Hard delete (Delete the records based on the id provided, to delete we need only id, deleted records can't be found in recycle bin, Note: If we enable bulk API in data loader settings then only we can perform Hard delete.)
  6. Export (From any object we can export records based on the SOQL query, Note: We can't export deleted records which are there in the recycle bin)
  7. Export all (From any object we can export records based on the SOQL query, Note: Using Export all we can export deleted records which are there in the recycle bin also)
After Exporting data using Data Loader, 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?
Excel does all sorts of “useful” operations 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 also break line. Best way as per my experience is Upload document to Google Drive. Export document back from Google drive as Excel.
5. What is the filed mapping file format of the data loader?
SDL( “Salesforce Data Loader” file of Field mapping)

Trigger Scenario: 
I have requirement fire the trigger when data is uploading through data loader. It should not execute when record saved from User interface? How to achieve that?


You could add a custom checkbox field which is hidden from the pagelayout.
· This field could be mapped to always insert as "true" with dataloader.
· Make your after insert trigger only execute conditionally on this field to be true.
· Optionally have your trigger set the field to false, or you could keep it as true to see that these records were imported through data loader.

Q) We are not providing some of fields in .csv file which are required in page layout level .what happens if we try to insert records into sales force through data loader ?
A) All records are inserting in sales force successfully.
Q) We are not providing some of fields in .csv file which are required in field level .what happens if we try to insert records into sales force through data loader ?

A) Except those records remaining records will be inserted in to sales force.

1. Is it necessary to define an explicit primary key in custom objects?
No. Every object has a standard field called id. There is no need to define an explicit primary key in custom objects. The standard id field can be used as primary key.

2. In which order, we upload data in salesforce for related objects?
When loading data into a salesforce application dependencies between objects determine the order in which objects are loaded. If there is a one-to-many relationship between A and B, the data for A should be loaded before the data for B.

3. What is Upsert and how external id are beneficial?
Upsert is an API function that combines insert and updates into a single call. Upsert uses an indexed custom field or external ID to determine whether to create a new object or update an existing object.

-If the external ID is not matched, then a new object is created
-If the external ID is matched once, then the existing object is updated
-If the external ID is matched multiple times, then an error is reported
Use Upsert when importing data to prevent the creation duplicates.

4. What is import wizard?
It is easy to use tool to load Accounts, Contacts, Leads, Solutions, or Custom Objects.

-Load 50,000 records or less.
-Prevent duplicates
-Doesn’t support all standard object but supports all custom object

5. Which is API based tool supported by Salesforce and what are its advantages?
Apex Data Loader

Advantages are:-

-Is a fully supported salesforce.com product.
-Supports import from CSV or export to CSV.
-Can be used to import or export more than 50,00 records.
-Supports loading from or exporting to a database via JDBC.
-Supports custom relationships for upsert.
-Can be run from command line.

6. Can we avoid duplicates using apex data loader which we can do through import wizard?
No.

7. What is Bulk API?
The Bulk API is used to upload high volume of data (millions of records).
The Data Loader uses the SOAP-based Web Services API by default. To use the Bulk API instead, check “Bulk API” checkbox in apex data loader settings page.
When you check Bulk API checkbox, increases the batch (upto 10000 records) which is usually 200 in normal upload.
Hard delete bypasses the Recycle Bin, so deleted records do not consume storage space and there is no way to retrieve them.

8. What is difference between “Export” and “Export All” in apex data loader?
Export: It will fetch only active records from salesforce.
Export All: It will fetch active as well as records from recycle bin.

9. True or False: Users can mass transfer records to which they do not have read access?
False

10. What is DateTime format supported in .csv file for upload in salesforce?
YYYY-MM-DDThh:mm:ss.00Z

11. Is there is any option to specify time zone for uploading records in apex data loader?
Yes. Present in settings page of apex data loader.

12. When “Hard Delete” button will be enabled in apex data loader?
When you enable Bulk API setting in apex data loader.

How to handle comma within a field while uploading using Data Loader?

In a Data Loader .CSV, if there is a comma in field content, you will have to enclose the contents within double quotation marks: ” “.

Salesforce Data Loader: sandbox and null values

If you are using Salesforce Enterprise Edition or Unlimited Edition, you can use Data Loader to import, update, delete or export data to/from any object in Salesforce.com

Login to sandbox instance
By default, after Data Loader installed, it is configure to login to Production instance. You need to change in Data Loader setting to point it to sandbox instance.
Goto Settings and find "Server host (clear to turn off)", type: https://test.salesforce.com

Update fields to null
If you update a field to null / blank, and you notice the data is stay the same (not updated to blank), you need to change in Data Loader setting.
Goto Settings and find "Insert null values" and tick this checkbox.








Mass upload/insert non-English characters to Salesforce

We can mass upload / insert data to Salesforce easily using Data Loader or other API tool. But, if we get the data in Excel file with non-English characters, non-English characters will be come ?? if we save it to CSV file directly from Ms Excel.

To able to upload in non-English characters, the file should be in UTF-8 and here is a step by step procedure that needs to be done since it is a limitation of Excel to save non-English character to csv file.

[ MS Excel ]
1. Open the *.xlsx file from MS Excel
2. Click menu > Save As
3. Put any name for the file and choose "Unicode Text (*.txt)" for "Save as type :" and Click Save

[ MS Notepad ]
4. Open the unicode text file using Microsoft Notepad. Some characters can appear as a box, however, this is because Notepad cannot display some unicode characters, so you can ignore this at this point.
5. It must be the tab delimitered file. Replace tabs with comma (,)
- select tab character by dragging the character between two column headers and press Ctrl+C
- Replace all tab characters with comma using Replace function (Ctrl+H)
6. In notepad, Click Save As
7. Put a filename and change Encoding: to "UTF-8"
8. Click Save.

[ Windows File Explorer]
9. Change the file extension from "*.txt" to "*.csv". The file icon should be changed to MS Excel now. If it is not changed, check Windows Folder options. (Windows Start menu > Control Panel > Folder Options > View tab > uncheck "Hide extensions for known file types"). This will show the file extensions. Try changing the file extension again.

[ MS Excel ]
10. Open this CSV file from Excel and verify if the data is okay.
*** Even if you find any problem in this step, you should NOT save the file from Excel. It will cause the encoding problem!! Just check the data only in Excel. If you see a data problem at this stage, fix the data from the original spreadsheet and repeat the steps again. Or, you can change it from Notepad but should ensure that the file is saved as UTF-8 format.

You can download sample csv file with non-English characters saved in UTF-8 encoding here.

Relationships in Salesforce :

What are the difference between Lookup and Master Detail relationship?

Ans: Difference between Lookup and Master-Detail relationship are

Master Detail
 1. Cascade record deletion 
 2. Child record must have a parent
 3. Cascade record level security
 4. Standard Object can not be on detail side of Master Detail
 5. Roll-up summary fields on parent object
 6. Master Detail relationship field is required on the page layout  of the detail record

Lookup
 1. This is optional, no parent requirement 
 2. No impact on record security
 3. Roll-up summary fields cannot be established
 4. Lookup relationship is not automatically required

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”.

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.
Can a standard object become child in master detail relationship?
No. Standard objects always remain master.

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.

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.

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.

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.

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.

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.

one master object A is private and other master object B is public then what is OWD for child object c?

A)Private.

if we have two objects A and B .and we have trigger on A to insert record in b.But user doesn't have access to B object what happens then?

A)Yes insert record ,Because trigger can run in system mode.


Here is the relationship between Opportunity,OpportulityLineItem ,PricebookEntry,Pricebook and Product2 .


Here's a schematic of the relationships involved.
User-added image


1. OpportunitylineItem is junction object between opportunity and pricebookentry.
    As We need PricebookEntry Id and opportunity Id while creating OpportunityLineItems.

2. PricebookEntry is a junction object between Product2 and PriceBook.
    As we need Product2 Id and PriceBook2 Id while creating PricebookEntries.

Currently I do the following to create a one-to-one relation between two objects:

  1. Create a lookup field on the child
  2. Create a unique field on the child, and hide this field from all page-layouts
  3. Write a workflow, for any change of the lookup field, to copy that value from the lookup field into the unique field

This process has many overheads:


  1. Extra field is required
  2. Unique criteria is utilized (we only get 3 unique fields per object)
  3. Workflow is used

 

What are the different types of object relations in salesforce? How can you create them?

No list of Salesforce interview questions is complete without involving relationships between objects in Salesforce. Relationships in Salesforce can be used to establish links between two or more objects.
The different types of object relationships in Salesforce are:
Master-Detail Relationship (1:n):-
It is a parent-child relationship in which the master object controls the behavior of the dependent child object. It is a 1:n relationship, in which there can be only one parent, but many children.
The main concept you need to be know is that, being the controlling object, the master field cannot be empty. If a record/ field in master object is deleted, the corresponding fields in the dependent object are also deleted. This is called a cascade delete. Dependent fields will inherit the owner, sharing and security settings from its master.
You can define master-detail relationships between two custom objects, or between a custom object and standard object as long as the standard object is the master in the relationship.
LookupRelationship(1:n):-
Lookup relationships are used when you want to create a link between two objects, but without the dependency on the parent object. Similar to Master-Detail relationship, you can think of this as a form of parent-child relationship where there is only one parent, but many children i.e. 1:n relationship.
The difference here is that despite being controlling field, deleting a record will not result in automatic deletion of the lookup field in the child object. Thus the records in the child object will not be affected and there is no cascade delete here. Neither will the child fields inherit the owner, sharing or security settings of its parent.
JunctionRelationship(Many-To-Many):-
This kind of a relationship can exist when there is a need to create two master-detail relationships. Two master-detail relationships can be created by linking 3 custom objects. Here, two objects will be master objects and the third object will be dependent on both the objects. In simpler words, it will be a child object for both the master objects.

What happens to detail record when a master record is deleted? What happens to child record when a parent record is deleted?

In a Master-Detail relationship, when a master record is deleted, the detail record is deleted automatically (Cascade delete).
In a Lookup relationship, even if the parent record is deleted, the child record will not be deleted.

Can you have a roll up summary field in case of Master-Detail relationship?

Yes. You can have a roll-up summary in case of a master-detail relationship. But not in case of a lookup relationship.

Salesforce: Master-Detail relationship (in detail)

One of the most advantage using Master-Detail relationship compare to Lookup relationship is Roll-Up Summary. In Master-Detail relationship, we can create roll-up summary field in master record to summarize / count data from child records.

Few items to notice when create roll-up summary field:
Parent record is locked
If you implement approval process with lock record, user will not able to create new child record if Sharing Setting in Master-Detail option is Read/Write.
Solution: change the sharing setting to Read Only.







Validation rule on parent record
If user not able to edit parent record and you have roll-up summary in parent record, user will not able to create or edit child record.
Solution: remove roll-up summary fields.

Can I change field type from Master-Detail to Lookup relationship?
Yes, make sure there is no roll-up summary fields in parent record, also in Deleted Fields (erase from Deleted Fields).

Can I change field type from Lookup to Master-Detail relationship?
Yes, all parent record should be not blank.



Master-Detail relationship



Sometimes new admin confuse what is the different between Master-Detail relationship with Lookup relationship, since both are used to link an object to another object and you can use parent-child relationships in SOQL queries.

But, fundamentally it is different between Master-Detail with Lookup relationship. Few items you need to notice on Master-Detail relationship:

  1. When a record of the master object is deleted, its related detail records are also deleted.
  2. The owner field on the detail object is not available and is automatically set to the owner of its associated master record.
  3.  The detail record inherits the sharing and security settings of its master record.
  4. The master-detail relationship field is required on the page layout of the detail record.
  5. By default, records can’t be reparented in master-detail relationships. Administrators can, however, allow child records in master-detail relationships on custom objects to be reparented to different parent records by selecting the Allow reparenting option in the master-detail relationship definition.
  6. You can define master-detail relationships between custom objects
  7. You also can define master-detail relationships between a custom object and a standard object, but the standard object cannot be on the detail side of a relationship with a custom object. In addition, you cannot create a master-detail relationship in which the User or Leadobjects are the master.
  8. You can display detail object record as custom related list on master object page layouts.
  9. You can use master-detail relationships to model many-to-many relationships between any two objects. Maximum 2 master-detail relationship from a custom object.
  10. If the object is master of 1 or more detail object, you only can have 1 parent object for that object.

Salesforce Opportunity Roll-Up

Roll-Up summary field is a nice feature in Salesforce to summary data from child record to parent within Master-Detail relationship object.

Although, Account and Opportunity is standard Salesforce object, but we can set Roll-Up summary for many purposes.

Date of last won deal
We can easily know and display when closed won opportunity in Account page layout without complex triggers.
Create roll-up summary field in Account with
- Summarized Object = Opportunity
- Field to Aggregate = Opportunity: Close Date
- Filter Criteria = Won EQUALS True
- Summary Type = MAX

Number of Opportunities


Display number of opportunities in Account page layout


Create roll-up summary field in Account with
- Summarized Object = Opportunity
- Filter Criteria =
- Summary Type = COUNT

Number of Won Opportunities
Display number of won opportunities in Account page layout
Create roll-up summary field in Account with
- Summarized Object = Opportunity
- Filter Criteria = Won EQUALS True
- Summary Type = COUNT

Total Amount of Won Opportunities
Display total amount of won opportunities in Account page layout

Create roll-up summary field in Account with
- Summarized Object = Opportunity
- Field to Aggregate = Opportunity: Amount
- Filter Criteria = Won EQUALS True
- Summary Type = SUM

Win Percentage
Display percentage of closed won opportunity for account
Create formula field with return type = Percent, with 2 decimal place
Formula = IF(Count_of_Opportunities__c > 0, Count_Won_Opportunities__c / Count_of_Opportunities__c,0)