|
| 1 | +# **Meta Form Fetching & Mapping in OneLead** |
| 2 | + |
| 3 | +Once your **Meta Ads Page Config** is set up and leads are being received in **Meta Webhook Lead Logs**, the next step is **fetching and mapping lead forms**. This ensures that incoming lead data is correctly assigned to your CRM lead doctype fields. |
| 4 | + |
| 5 | + |
| 6 | +## **Page Configuration** |
| 7 | +To find the **pages** associated with your Meta Ad Account: |
| 8 | +- Navigate to **OneLead > Meta Ads Page Config**. |
| 9 | +- This will display a **list of page names** linked to your **user_adaccounts**. |
| 10 | +- Alternatively, check **OneLead > Meta Page** to see the **full list of fetched pages**. |
| 11 | + |
| 12 | +**Meta Ads Page Config:** |
| 13 | + |
| 14 | + |
| 15 | +### **Verify Lead Doctype Reference** |
| 16 | +- In **Meta Ads Page Config**, ensure that **"Lead Doctype Reference"** is set. |
| 17 | +- This acts as a **global setting** to assign all lead forms under this page to a specific **Lead Doctype**. |
| 18 | +- You can override this **per individual form** later. |
| 19 | + |
| 20 | +Ensure that your page is enabled to allow lead entries. If disabled, it will appear as **disabled** in **Meta Webhook Lead Logs**. |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +### **Mapping Meta Lead Forms** |
| 25 | + 1. **Open the Page Configuration** (Meta Ads Page Config). |
| 26 | + 2. Under the **mapping child table**, add a new row and select a **Meta Lead Form** from the Forms List. |
| 27 | + 3. Click the **Quick Map button** (**Note**: Due to a Frappe table issue, the button will not appear until you select a row). |
| 28 | + 4. This will open the **Quick Map Lead Fields** pop-up. |
| 29 | + |
| 30 | +**Forms List & Quick Map Button:** |
| 31 | + |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## **Quick Map Lead Fields** |
| 36 | +In the **Quick Map Lead Fields** pop-up, you will see: |
| 37 | + |
| 38 | +| Column | Description | |
| 39 | +|--------|------------| |
| 40 | +| **Meta Field** | Fields available in the Meta Lead Form. | |
| 41 | +| **Lead Doctype Field** | Fields from the selected **Lead Doctype Reference**. | |
| 42 | +| **Default Value** | Hardcoded values for this field, applied to all leads under this form. | |
| 43 | +| **Formatting Function** | Helper function to modify/sanitize the field value before saving. | |
| 44 | +| **Function Parameters** | If a function requires additional parameters, pass them as a JSON object. | |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +### **Understanding Field Mapping Logic** |
| 49 | +- **Meta Field → Lead Doctype Field Mapping** |
| 50 | + - Assign Meta form fields to corresponding CRM fields. |
| 51 | + - Ensure **mandatory fields** in the Lead Doctype are mapped correctly. |
| 52 | + |
| 53 | +- **Default Value** |
| 54 | + - If a field is missing in Meta Lead Form, **you can hardcode a value**. |
| 55 | + |
| 56 | + - **Field Lookup Order (Dynamic Values)** |
| 57 | + If a default value field is mapped using **`field:field_name`**, OneLead searches for the field_name value in this order: |
| 58 | + 1. **Meta Webhook Lead Logs** |
| 59 | + 2. **Meta Lead Form** |
| 60 | + 3. **Meta Ads Page Config** |
| 61 | + |
| 62 | + - If no value is found, an error is raised in **Meta Webhook Lead Logs**. |
| 63 | + |
| 64 | +- **Formatting Function** |
| 65 | + - Choose a function to **modify data before storing** (e.g., phone number formatting). |
| 66 | + - Custom functions can be added via **Server Scripts** and handled in **Lead doctype event (`validate` or `before_save`)**. |
| 67 | + |
| 68 | +- **Function Parameters** |
| 69 | + - column available in form view. |
| 70 | + - If a **custom function** requires parameters, pass them as a **JSON object**. |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +### **Saving & Populating Forms** |
| 75 | + - Once all fields are mapped, **click Save Mappings**. |
| 76 | + - Save the **Meta Ads Page Config**. |
| 77 | + |
| 78 | +#### **Troubleshooting** |
| 79 | +- If a **form is missing** in Meta Lead Form, click **Populate Forms** to fetch all latest forms for that page. |
| 80 | + |
| 81 | +<!-- **Populate Forms Button:** |
| 82 | + --> |
| 83 | + |
| 84 | + |
| 85 | +### **Next Steps** |
| 86 | +- [Verify Webhook Lead Logs](../meta/meta_lead_testing.md) |
| 87 | +- [Handle Missing Leads in OneLead](../../troubleshooting/meta_webhook_issues.md) |
| 88 | +- [Customize Field Mapping Using Server Scripts](../custom_scripts.md) |
| 89 | + |
| 90 | +This completes the **Meta Form Fetching & Mapping** setup for OneLead. |
0 commit comments