# Create Opp from Contact

{% embed url="<https://www.youtube.com/watch?index=4&list=PLS9gb0Qneac2EIlybS-X1aC418MDsAasb&pp=iAQB&v=bEmSvAXTV5w>" %}

## Opportunity Creation Directly from Contact Record

### Overview

This document outlines a method for creating opportunities directly from the contact record in Salesforce, streamlining the opportunity creation process, and ensuring accurate attribution data.

### Benefits

There are several benefits to creating opportunities directly from the contact record:

* **Streamlined process:** All users will follow the same process for opportunity creation, ensuring consistency and reducing errors.
* **Accurate attribution:** By tying the account record, opportunity record, and primary contact to the opportunity, attribution fields in Salesforce are accurately populated, providing valuable insights into lead sources and campaign performance.
* **Customization:** Additional fields can be prepopulated based on the contact record, ensuring that opportunities are created with the necessary information.

### Prerequisites

* Salesforce Administrator permissions
* Familiarity with JavaScript

### Instructions

#### 1. Create a Custom Button on the Contact Object

1. Go to the **Contact** object manager.
2. Click the **Buttons, Links, and Actions** button.
3. Click the **New Button** button.
4. Enter the following information:
   * **Label:** New Opportunity
   * **Name:** New\_Opportunity
   * **Display Type:** Detail Page Button
   * **Behavior:** Display in existing window with sidebar
   * **Content Source:** URL
   * **URL:** `/lightning/o/Opportunity/new?account={!Account.Id}&primary_contact_id={!Contact.Id}&stage_name={!Stage_Name}&probability={!Probability}&forecast_category={!Forecast_Category}&Name={!Name}&CloseDate={!CloseDate}`
5. Click the **Save** button.

#### 2. Add the Custom Button to the Contact Page Layout

1. Go to the **Contact** object manager.
2. Click the **Page Layouts** button.
3. Click the **Edit** button next to the desired page layout.
4. Drag the **New Opportunity** button to the desired location on the page layout.
5. Click the **Save** button.

#### 3. Customize the Opportunity Creation Form (Optional)

The URL in the custom button can be customized to prepopulate additional fields on the opportunity creation form. To do this, add the desired field names, API names, and values to the URL, separated by commas. For example:

{% code overflow="wrap" %}

```
/lightning/o/Opportunity/new?account={!Account.Id}&primary_contact_id={!Contact.Id}&stage_name={!Stage_Name}&probability={!Probability}&forecast_category={!Forecast_Category}&Name={!Name}&CloseDate={!CloseDate}&amount={!Amount}&type={!Type}
```

{% endcode %}

### Usage

Once the custom button has been created and added to the contact page layout, users can create opportunities directly from the contact record by clicking the **New Opportunity** button. The opportunity will be created with the specified account, primary contact, stage name, probability, forecast category, name, and close date. Additional fields can be prepopulated by customizing the URL in the custom button.
