### Install Frontend Dependencies and Start Development Server Source: https://github.com/frappe/crm/blob/develop/_autodocs/configuration.md Installs project dependencies using Yarn and starts the Vite development server for the frontend. ```bash cd frontend yarn install yarn dev ``` -------------------------------- ### Local Installation of Frappe CRM Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Steps to set up a Frappe bench, install the CRM app, create a new site, and start the development server. ```bash # Setup Frappe bench bench new-app crm # Install CRM bench get-app crm # Create site bench new-site crm.localhost --install-app crm # Start dev server bench start # Frontend development (separate terminal) cd apps/crm/frontend yarn dev ``` -------------------------------- ### Install Frappe CRM App Locally Source: https://github.com/frappe/crm/blob/develop/README.md Commands to install the Frappe CRM app within a local Frappe Bench setup. Ensure 'bench start' is running in another terminal. ```bash $ bench get-app crm $ bench new-site sitename.localhost --install-app crm $ bench browse sitename.localhost --user Administrator ``` -------------------------------- ### Clone and Install Frappe UI Starter Source: https://github.com/frappe/crm/blob/develop/frontend/README.md Steps to clone the starter template into an existing Frappe app and install dependencies. ```bash cd apps/todo npx degit netchampfaris/frappe-ui-starter frontend cd frontend yarn yarn dev ``` -------------------------------- ### Download Easy Install Script for Production Source: https://github.com/frappe/crm/blob/develop/README.md Use this command to download the Frappe CRM easy install script for production environments. ```bash wget https://frappe.io/easy-install.py ``` -------------------------------- ### Run Frappe CRM Frontend Development Server Source: https://github.com/frappe/crm/blob/develop/README.md Install frontend dependencies and start the development server for Frappe CRM. Access the site on the specified vite dev server port. ```bash yarn install yarn dev ``` -------------------------------- ### Configure Event Notifications Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/event-todo-api.md Set up email notifications for an event, specifying when they should be sent relative to the event start time. This example demonstrates creating an 'Event' doctype with custom notification intervals. ```python event = frappe.get_doc({ 'doctype': 'Event', 'subject': 'Sales Meeting with Client', 'starts_on': '2024-02-15 14:00:00', 'ends_on': '2024-02-15 15:00:00', 'participants': [ {'email': 'salesperson@example.com'}, {'email': 'client@example.com'} ], 'event_notifications': [ { 'type': 'Email', 'interval': 'minutes', 'before': 30, }, { 'type': 'Email', 'interval': 'days', 'before': 1, } ] }) event.insert() ``` -------------------------------- ### Start Frappe CRM with Docker Compose Source: https://github.com/frappe/crm/blob/develop/README.md Use this command to start the Frappe CRM containers in detached mode. ```bash docker compose up -d ``` -------------------------------- ### is_frappe_version Source: https://github.com/frappe/crm/blob/develop/_autodocs/utilities.md Compares the installed Frappe framework version against a specified version. ```APIDOC ## is_frappe_version(version: str, above: bool = False, below: bool = False) -> bool ### Description Compares major version numbers. Uses current Frappe version obtained from the framework. ### Method ```python def is_frappe_version(version: str, above: bool = False, below: bool = False) -> bool ``` ### Parameters #### Path Parameters - **version** (str) - Required - Version string (e.g., "16.0.0") - **above** (bool) - Optional - Check if installed version is >= specified version - **below** (bool) - Optional - Check if installed version is < specified version ### Return Type `bool` — True if version check matches ### Example ```python from crm.utils import is_frappe_version if is_frappe_version("16", above=True): # Running Frappe v16 or higher use_new_api() else: # Running Frappe v15 use_legacy_api() if is_frappe_version("15"): # Exact version match (major version 15) pass ``` ``` -------------------------------- ### Frontend Build Process Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Commands to install dependencies and build the frontend application. Use 'yarn dev' for development and 'yarn build' for production. ```bash cd frontend yarn install yarn dev # Development yarn build # Production ``` -------------------------------- ### JavaScript API: Get Translations Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Example of fetching translation strings using the Frappe JavaScript API. Useful for internationalization. ```javascript // Get translations frappe.call({ method: 'crm.api.get_translations', callback: (r) => { /* ... */ } }) ``` -------------------------------- ### Example: Add Existing Users to CRM Role Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/user-api.md Shows how to use the add_existing_users API with a list of user emails and a target role. ```javascript response = frappe.call({ 'method': 'crm.api.user.add_existing_users', 'args': { 'users': ['alice@example.com', 'bob@example.com'], 'role': 'Sales User' } }) ``` -------------------------------- ### Example: Update User Role Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/user-api.md Illustrates calling the update_user_role API to assign a new role to a user, with a callback for success confirmation. ```javascript response = frappe.call({ 'method': 'crm.api.user.update_user_role', 'args': { 'user': 'salesperson@example.com', 'new_role': 'Sales Manager' }, 'callback': function(r) { console.log('Role updated'); } }) ``` -------------------------------- ### Docker Setup for Frappe CRM Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Instructions to launch Frappe CRM using Docker Compose. Access the application via the specified URL. ```bash docker compose up -d # Access at http://crm.localhost:8000/crm ``` -------------------------------- ### Example: Change User Password Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/user-api.md Demonstrates how to call the change_password API method using a JavaScript client. Handles success and error responses. ```javascript response = frappe.call({ 'method': 'crm.api.user.change_password', 'args': { 'old_password': 'current_password_123', 'new_password': 'new_secure_password_456' }, 'callback': function(r) { console.log(r.message); // 'Password Updated Successfully' }, 'error': function(r) { // Handle incorrect old password or weak new password } }) ``` -------------------------------- ### Call get_assigned_users API Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Example of how to call the get_assigned_users API from the client-side. It logs the list of assigned users to the console. ```javascript response = frappe.call({ 'method': 'crm.api.doc.get_assigned_users', 'args': { 'doctype': 'CRM Deal', 'name': 'DEAL-001' }, 'callback': function(r) { console.log(r.message); // ['user1@example.com', 'user2@example.com'] } }) ``` -------------------------------- ### JavaScript API: Get User Signature Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Example of fetching the current user's signature using the Frappe JavaScript API. May be used for document signing or identification. ```javascript // Get user signature frappe.call({ method: 'crm.api.get_user_signature', callback: (r) => { /* ... */ } }) ``` -------------------------------- ### Client-side Call to Get Views Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/views-api.md Demonstrates how to call the get_views API from the client-side using Frappe's call method and process the response. ```javascript response = frappe.call({ 'method': 'crm.api.views.get_views', 'args': { 'doctype': 'CRM Lead' }, 'callback': function(r) { r.message.forEach(view => { console.log(view.title); // e.g., 'My Leads', 'Hot Leads' console.log(view.type); // 'list', 'kanban', etc. console.log(view.user); // '' for global, email for user-specific if (view.type === 'kanban') { console.log(view.kanban_fields); console.log(view.kanban_columns); } }); } }) ``` -------------------------------- ### Call OAuth Providers API Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Example of how to call the `oauth_providers` API method from a Frappe client. This demonstrates fetching provider details and logging them. ```javascript response = frappe.call({ 'method': 'crm.api.auth.oauth_providers', 'allow_guest': True, 'callback': function(r) { r.message.forEach(provider => { console.log(provider.provider_name); console.log(provider.auth_url); console.log(provider.icon); }); } }) ``` -------------------------------- ### Compare Frappe Framework Version Source: https://github.com/frappe/crm/blob/develop/_autodocs/utilities.md Check the installed Frappe framework version against a specified version string. Supports checking for exact matches, versions above, or versions below. ```python from crm.utils import is_frappe_version if is_frappe_version("16", above=True): # Running Frappe v16 or higher use_new_api() else: # Running Frappe v15 use_legacy_api() if is_frappe_version("15"): # Exact version match (major version 15) pass ``` -------------------------------- ### Call get_fields API Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Example of calling the get_fields API to retrieve fields for a 'CRM Lead' document type. ```javascript response = frappe.call({ 'method': 'crm.api.doc.get_fields', 'args': { 'doctype': 'CRM Lead' } }) ``` -------------------------------- ### Get Activities for a Document Source: https://github.com/frappe/crm/blob/develop/_autodocs/INDEX.md Retrieve all activities and history associated with a specific document, identified by its name. ```python frappe.call({ method: 'crm.api.activities.get_activities', args: {name: 'LEAD-001'} }) ``` -------------------------------- ### Call get_linked_deals API Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/contact-api.md Example of how to call the get_linked_deals API and process the response. It logs the organization, status, and deal owner for each returned deal. ```JavaScript response = frappe.call({ 'method': 'crm.api.contact.get_linked_deals', 'args': { 'contact': 'CONT-001' }, 'callback': function(r) { r.message.forEach(deal => { console.log(deal.organization); console.log(deal.status); console.log(deal.deal_owner); }); } }) ``` -------------------------------- ### JavaScript Example for get_activities Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/activities-api.md This JavaScript snippet demonstrates how to call the `get_activities` method using `frappe.call` and process the returned activity data. It logs the activity type and data for each activity in the stream. ```JavaScript response = frappe.call({ 'method': 'crm.api.activities.get_activities', 'args': { 'name': 'LEAD-001' }, 'callback': function(r) { const activities = r.message[0]; const calls = r.message[1]; const notes = r.message[2]; const tasks = r.message[3]; const attachments = r.message[4]; activities.forEach(activity => { console.log(activity.activity_type); // 'creation', 'changed', etc. console.log(activity.data); }); } }) ``` -------------------------------- ### JavaScript API Call Example Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Demonstrates how to make API calls using Frappe's JavaScript client. This is the standard way to interact with the CRM API from the frontend. ```APIDOC ## JavaScript API Call Example ### Description This snippet shows the standard format for making asynchronous API calls from the Frappe frontend using `frappe.call`. It includes parameters for the method, arguments, and callbacks for success and error handling. ### Method POST (implied by `frappe.call`) ### Endpoint `crm.api.module.function_name` (example) ### Parameters #### Request Body - **method** (string) - Required - The API method to call. - **args** (object) - Optional - Parameters to pass to the API method. - **callback** (function) - Optional - Function to execute upon successful API response. - **error** (function) - Optional - Function to execute if an API error occurs. ### Request Example ```javascript frappe.call({ method: 'crm.api.module.function_name', args: { param1: 'value1', param2: 'value2' }, callback: function(r) { if (!r.exc) { console.log(r.message); } }, error: function(r) { console.error(r.message); } }) ``` ### Response #### Success Response - **message** (any) - The data returned by the API method. #### Response Example ```json { "message": "Success data" } ``` ### Error Handling Errors are handled via the `error` callback and follow Frappe's exception model. ``` -------------------------------- ### Permission Denied Error Response Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Example of a JSON response when a user attempts to access resources without sufficient permissions. Includes error type, message, and title. ```json { "exc": "frappe.PermissionError", "msg": "You are not permitted to access CRM resources.", "title": "Insufficient Permission" } ``` -------------------------------- ### Not Authenticated Error Response Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Example of a JSON response when a request is made by an unauthenticated user. Indicates that login is required. ```json { "exc": "frappe.AuthenticationError", "msg": "You must be logged in.", "title": "Not Authenticated" } ``` -------------------------------- ### Get File Uploader Defaults Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Retrieve default configurations for the file uploader, specific to a document type. This helps in setting up file upload interfaces. ```python response = frappe.call({ 'method': 'crm.api.get_file_uploader_defaults', 'args': {'doctype': 'CRM Lead'} }) config = response.message ``` -------------------------------- ### Python API Call Example Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Illustrates how to invoke CRM API methods using Frappe's Python client. This is typically used for backend integrations or scripts. ```APIDOC ## Python API Call Example ### Description This snippet demonstrates how to call CRM API methods from a Python environment using the `frappe.call` function. It shows how to pass arguments and access the response. ### Method POST (implied by `frappe.call`) ### Endpoint `crm.api.module.function_name` (example) ### Parameters #### Request Body - **method** (string) - Required - The API method to call. - **args** (object) - Optional - Parameters to pass to the API method. ### Request Example ```python import frappe response = frappe.call( 'crm.api.module.function_name', args={ 'param1': 'value1', 'param2': 'value2' } ) result = response.get('message') ``` ### Response #### Success Response - **message** (any) - The data returned by the API method. #### Response Example ```json { "message": "Success data" } ``` ``` -------------------------------- ### get_activities Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/activities-api.md Get complete activity stream for a Lead or Deal. This is the primary method for retrieving all associated activities, calls, notes, tasks, and attachments. ```APIDOC ## get_activities(name: str) ### Description Get complete activity stream for a Lead or Deal. Returns activities (sorted by creation desc), linked calls, notes, tasks, and attachments. If the document is a Deal with a Lead, includes the Lead's activities as well. ### Method POST ### Endpoint /frappe/crm/api/activities/get_activities ### Parameters #### Query Parameters - **name** (str) - Required - Name of CRM Lead or CRM Deal document ### Request Example ```json { "jsonrpc": "2.0", "method": "crm.api.activities.get_activities", "params": { "name": "LEAD-001" }, "id": 1 } ``` ### Response #### Success Response (200) - **message** (tuple[list, list, list, list, list]) - Tuple of (activities, calls, notes, tasks, attachments) #### Response Example ```json { "jsonrpc": "2.0", "result": [ [ { "activity_type": "creation", "creation": "2023-10-27 10:00:00", "owner": "user@example.com", "data": {}, "is_lead": true, "name": "LEAD-001", "content": null, "communication_type": null, "communication_date": null, "options": null, "other_versions": [] } ], [], [], [], [] ], "id": 1 } ``` ### Throws - **frappe.DoesNotExistError** if document not found ``` -------------------------------- ### Get Deals Linked to a Contact Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Retrieve all deals that are associated with a specific contact. Use this to view the sales pipeline related to a contact. ```python response = frappe.call({ 'method': 'crm.api.contact.get_linked_deals', 'args': {'contact': 'CONTACT-001'} }) deals = response.message ``` -------------------------------- ### Frontend OAuth Provider Integration Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Example of fetching OAuth providers in a Vue.js frontend and rendering login buttons. This code dynamically creates anchor tags for each provider, linking to their respective authorization URLs. ```javascript // Fetch OAuth providers for login page const providers = await frappe.call({ method: 'crm.api.auth.oauth_providers' }); // Render login buttons providers.message.forEach(provider => { // Create login button const button = document.createElement('a'); button.href = provider.auth_url; button.innerHTML = provider.icon + ' ' + provider.provider_name; loginContainer.appendChild(button); }); ``` -------------------------------- ### Get Assigned Users for a Document Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Retrieves a list of users assigned to a specific document. If no assignments exist, it can return a default user if provided. ```python def get_assigned_users(doctype: str, name: str | int, default_assigned_to: str | None = None) -> list[str] ``` -------------------------------- ### Get File Uploader Defaults Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Retrieves default configuration settings for the file upload interface, typically used to initialize the file upload component. ```APIDOC ## POST /api/method/crm.api.get_file_uploader_defaults ### Description Fetches default settings and configurations required for the file upload interface. ### Method POST ### Endpoint /api/method/crm.api.get_file_uploader_defaults ### Parameters #### Request Body - **doctype** (string) - Required - The document type for which to get the file uploader defaults. ``` -------------------------------- ### Commit Style Guide Source: https://github.com/frappe/crm/blob/develop/AGENTS.md Standard commit message format for feature, fix, refactor, test, and docs changes. Use multiple commits for logical changes. ```git feat: short description fix: short description refactor: short description test: short description docs: short description ``` -------------------------------- ### Get CRM Leads with Filters Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Retrieve a list of CRM leads, applying filters, sorting, and pagination. Use this to fetch specific lead subsets based on criteria like status. ```python response = frappe.call({ 'method': 'crm.api.doc.get_data', 'args': { 'doctype': 'CRM Lead', 'filters': {'status': 'New'}, 'order_by': 'modified desc', 'page_length': 20 } }) ``` -------------------------------- ### Get All Views for a Doctype Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/views-api.md Retrieves all available CRM View Settings for a specified doctype, including both global and user-specific views. User-specific views take precedence. ```python import frappe @frappe.whitelist() def get_views(doctype: str) -> list[dict]: """Get all available views for a document type.""" pass ``` -------------------------------- ### Get Quick Filters for CRM Lead Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Fetches configured quick filters for CRM Lead documents. This can be used to display predefined filtering options. ```javascript response = frappe.call({ 'method': 'crm.api.doc.get_quick_filters', 'args': { 'doctype': 'CRM Lead', 'cached': true } }) ``` -------------------------------- ### Call search_emails API Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/contact-api.md Example of calling the search_emails API with a search term. It iterates through the results and logs the full name and email of each matching contact. ```JavaScript response = frappe.call({ 'method': 'crm.api.contact.search_emails', 'args': { 'txt': 'john' }, 'callback': function(r) { r.message.forEach(row => { const [fullName, email, id] = row; console.log(fullName, email); }); } }) ``` -------------------------------- ### Get Activity Stream for a Lead Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Fetch all activities, calls, notes, tasks, and attachments associated with a specific lead. This is useful for reviewing a lead's history. ```python response = frappe.call({ 'method': 'crm.api.activities.get_activities', 'args': {'name': 'LEAD-001'} }) activities, calls, notes, tasks, attachments = response.message ``` -------------------------------- ### Call create_new API to add email Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/contact-api.md Example of calling the create_new API to add a new email address to a contact. Ensure the 'field' is 'email' and 'value' is a valid email format. ```JavaScript response = frappe.call({ 'method': 'crm.api.contact.create_new', 'args': { 'contact': 'CONT-001', 'field': 'email', 'value': 'newemail@example.com' } }) ``` -------------------------------- ### Get File Uploader Defaults for Document Type Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/core-api.md Retrieves file upload configuration settings for a given document type. This includes allowed file types, maximum file size, and other relevant upload parameters. ```python @frappe.whitelist() def get_file_uploader_defaults(doctype: str) -> dict: pass ``` ```javascript response = frappe.call({ 'method': 'crm.api.get_file_uploader_defaults', 'args': { 'doctype': 'CRM Lead' }, 'callback': function(r) { console.log(r.message.max_file_size); console.log(r.message.allowed_file_types); } }) ``` -------------------------------- ### Download Initialization Script for Docker Source: https://github.com/frappe/crm/blob/develop/README.md Download the init.sh script required for initializing the Frappe CRM Docker environment. ```bash wget -O init.sh https://raw.githubusercontent.com/frappe/crm/develop/docker/init.sh ``` -------------------------------- ### Deploy Frappe CRM in Production Source: https://github.com/frappe/crm/blob/develop/README.md Run the easy-install script to deploy a production-ready Frappe CRM instance. Replace placeholder values with your specific details. ```bash python3 ./easy-install.py deploy \ --project=crm_prod_setup \ --email=email.example.com \ --image=ghcr.io/frappe/crm \ --version=stable \ --app=crm \ --sitename subdomain.domain.tld ``` -------------------------------- ### Get Dashboard for User in Python Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Retrieve dashboard information for a specified user or the current user if none is provided. This function operates within the user's context. ```python @frappe.whitelist() def get_dashboard(user: str = None): if user is None: user = frappe.session.user # Get dashboard for specified user or current user ``` -------------------------------- ### Call API to Remove CRM Roles from User Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/user-api.md This example demonstrates how to call the `remove_crm_roles_from_user` API method using `frappe.call`. It includes a callback function to log the success message. ```javascript response = frappe.call({ 'method': 'crm.api.user.remove_crm_roles_from_user', 'args': { 'user': 'salesperson@example.com' }, 'callback': function(r) { console.log(r.message); // 'User has been removed from CRM roles.' } }) ``` -------------------------------- ### Call set_as_primary API Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/contact-api.md Example of calling the set_as_primary API to designate a specific email address as the primary contact method. Ensure the 'field' and 'value' correctly identify the desired contact method. ```JavaScript response = frappe.call({ 'method': 'crm.api.contact.set_as_primary', 'args': { 'contact': 'CONT-001', 'field': 'email', 'value': 'primary@example.com' } }) ``` -------------------------------- ### Build Frontend for Production Source: https://github.com/frappe/crm/blob/develop/_autodocs/configuration.md Builds the frontend application for production using Vite. ```bash cd frontend yarn build ``` -------------------------------- ### Get Complete Dashboard Layout Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/dashboard-api.md Fetches the complete dashboard layout with all configured charts and their data for a specified date range. Sales Users see their own data; Managers can view any user's data. ```javascript const response = await frappe.call({ method: 'crm.api.dashboard.get_dashboard', args: { from_date: '2024-01-01', to_date: '2024-01-31' } }); response.message.forEach(item => { console.log(item.name); // Chart name console.log(item.data); // Chart data }); ``` -------------------------------- ### Get Activities Source: https://github.com/frappe/crm/blob/develop/_autodocs/INDEX.md Retrieves the activity history for a specific document. ```APIDOC ## Get Activities ### Description Retrieves the activity history for a specific document, including versions and communications. ### Method POST (via frappe.call) ### Endpoint `crm.api.activities.get_activities` ### Parameters #### Arguments - **name** (string) - Required - The name or ID of the document to get activities for. ### Request Example ```python frappe.call({ method: 'crm.api.activities.get_activities', args: {name: 'LEAD-001'} }) ``` ### Response #### Success Response Returns a list of activities associated with the document. ``` -------------------------------- ### Get Translations Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Retrieves translation strings for the CRM system, useful for internationalization. ```APIDOC ## Get Translations ### Description This API endpoint retrieves translation strings used within the CRM application. It is essential for displaying localized content to users. ### Method POST (implied by `frappe.call`) ### Endpoint `crm.api.get_translations` ### Parameters This method does not require any specific arguments. ### Request Example ```javascript frappe.call({ method: 'crm.api.get_translations', callback: (r) => { /* handle translations */ } }) ``` ### Response #### Success Response - **message** (object) - An object containing translation keys and their corresponding values. #### Response Example ```json { "message": { "deals": "Deals", "contacts": "Contacts" } } ``` ``` -------------------------------- ### Get Cached Meta Source: https://github.com/frappe/crm/blob/develop/_autodocs/configuration.md Retrieves the metadata for a doctype from Frappe's cache. ```python # Get cached meta meta = frappe.get_meta("CRM Lead", cached=True) ``` -------------------------------- ### Get Cached Document Source: https://github.com/frappe/crm/blob/develop/_autodocs/configuration.md Retrieves a document from Frappe's cache layer. ```python # Get cached document doc = frappe.get_cached_doc("CRM Deal", "DEAL-001") ``` -------------------------------- ### Get Dashboard Source: https://github.com/frappe/crm/blob/develop/_autodocs/INDEX.md Retrieves dashboard analytics data for a specified date range. ```APIDOC ## Get Dashboard ### Description Retrieves dashboard analytics data, such as sales metrics, for a specified date range. ### Method POST (via frappe.call) ### Endpoint `crm.api.dashboard.get_dashboard` ### Parameters #### Arguments - **from_date** (string) - Required - The start date for the dashboard data (YYYY-MM-DD). - **to_date** (string) - Required - The end date for the dashboard data (YYYY-MM-DD). ### Request Example ```python frappe.call({ method: 'crm.api.dashboard.get_dashboard', args: { from_date: '2024-01-01', to_date: '2024-01-31' } }) ``` ### Response #### Success Response Returns dashboard analytics data, including sales metrics. ``` -------------------------------- ### Get Linked Deals Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Retrieves a list of deals that are associated or linked to a specific contact. ```APIDOC ## POST /api/method/crm.api.contact.get_linked_deals ### Description Fetches all deals that are linked to a given contact. ### Method POST ### Endpoint /api/method/crm.api.contact.get_linked_deals ### Parameters #### Request Body - **contact** (string) - Required - The name or ID of the contact for whom to retrieve linked deals. ``` -------------------------------- ### Get User Signature Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Fetches the current user's signature, likely for use in email or document generation. ```APIDOC ## Get User Signature ### Description This API endpoint retrieves the signature of the currently logged-in user. This is often used for automatically appending signatures to outgoing communications like emails. ### Method POST (implied by `frappe.call`) ### Endpoint `crm.api.get_user_signature` ### Parameters This method does not require any specific arguments. ### Request Example ```javascript frappe.call({ method: 'crm.api.get_user_signature', callback: (r) => { /* handle signature */ } }) ``` ### Response #### Success Response - **message** (string) - The user's signature. #### Response Example ```json { "message": "Best regards,\nJohn Doe" } ``` ``` -------------------------------- ### Download Docker Compose File for Frappe CRM Source: https://github.com/frappe/crm/blob/develop/README.md Download the docker-compose.yml file to set up Frappe CRM using Docker. ```bash wget -O docker-compose.yml https://raw.githubusercontent.com/frappe/crm/develop/docker/docker-compose.yml ``` -------------------------------- ### Call remove_linked_doc_reference API Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Example of calling the remove_linked_doc_reference API to remove a CRM Deal reference and delete the deal. ```javascript response = frappe.call({ 'method': 'crm.api.doc.remove_linked_doc_reference', 'args': { 'items': JSON.stringify([ {'doctype': 'CRM Deal', 'docname': 'DEAL-001'} ]), 'remove_contact': false, 'delete': true } }) ``` -------------------------------- ### Run Unit Tests Source: https://github.com/frappe/crm/blob/develop/AGENTS.md Commands to run unit tests in watch mode or for a single run. Ensure all tests pass before committing. ```bash cd frontend yarn test:run # single run yarn test # watch mode ``` -------------------------------- ### Get CRM Organizations Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Retrieves a list of all CRM organization documents. Use this to populate organization dropdowns or filters for deals. ```python import frappe @frappe.whitelist() def get_organizations() -> list[dict]: """Get list of all CRM organizations.""" pass ``` -------------------------------- ### Get Fields for a Document Type Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Fetches the fields associated with a given document type. Optionally includes all field types, not just those with values. ```python def get_fields(doctype: str, allow_all_fieldtypes: bool = False) -> list ``` -------------------------------- ### Get Translations Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/core-api.md Retrieves all translations for the user's configured language. It uses the logged-in user's preference or system settings. ```python @frappe.whitelist(allow_guest=True) def get_translations() -> dict ``` ```python import frappe response = frappe.call({ 'method': 'crm.api.get_translations', }) # response.message contains the translation dictionary ``` -------------------------------- ### User Context in API Methods Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Demonstrates how API methods can operate on the current user's context by default, with an option to specify a different user. ```APIDOC ## User Context ### Description API methods typically operate within the context of the currently logged-in user. This context can be explicitly overridden if needed. ### Example ```python @frappe.whitelist() def get_dashboard(user: str = None): if user is None: user = frappe.session.user # Logic to retrieve dashboard data for the specified or current user ``` ``` -------------------------------- ### Frontend Usage in Vue.js Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/views-api.md Shows how to fetch and filter views within a Vue.js frontend application using Frappe's client-side API. ```javascript // Get views for the current doctype const views = await frappe.call({ method: 'crm.api.views.get_views', args: { doctype: 'CRM Lead' } }); // Filter to user's views only const userViews = views.message.filter(v => v.user === frappe.session.user); // Filter by view type const kanbanViews = views.message.filter(v => v.type === 'kanban'); const listViews = views.message.filter(v => v.type === 'list'); ``` -------------------------------- ### Frappe Whitelisted API Methods Source: https://github.com/frappe/crm/blob/develop/_autodocs/configuration.md Demonstrates how to expose Python methods as API endpoints in Frappe. Use @frappe.whitelist() for logged-in users, allow_guest=True for public access, and specify HTTP methods for restricted access. ```python @frappe.whitelist() # Requires login def method_name(arg1, arg2): pass @frappe.whitelist(allow_guest=True) # Allows guest access def public_method(): pass @frappe.whitelist(methods=["POST", "DELETE"]) # Restrict HTTP methods def restricted_method(): pass ``` -------------------------------- ### Python API: Get Cached Document Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Retrieve documents from cache for improved performance. Use 'get_cached_doc' when the document is unlikely to have changed recently. ```python frappe.get_cached_doc(doctype, name) ``` -------------------------------- ### Get Linked Documents of a Specific Document Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Retrieves all documents that are linked to a particular document, including standard and dynamic links. Results are deduplicated. ```python def get_linked_docs_of_document(doctype: str, docname: str) -> list[dict] ``` -------------------------------- ### Standard Login Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Initiates a user login process by sending credentials to the /api/method/login endpoint. Upon successful validation, a session cookie is returned, which is used for subsequent authenticated requests. ```APIDOC ## POST /api/method/login ### Description Authenticates a user by validating their email and password. A successful login returns a session cookie for subsequent requests. ### Method POST ### Endpoint /api/method/login ### Parameters #### Request Body - **email** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. ### Response #### Success Response (200) - **session_cookie** (string) - The session identifier returned upon successful login. #### Response Example ```json { "sid": "your_session_id" } ``` ``` -------------------------------- ### Invite Users via Email Source: https://github.com/frappe/crm/blob/develop/_autodocs/INDEX.md Send invitations to new users via email, assigning them a specific role upon joining. Ensure the email address and role are correctly specified. ```python frappe.call({ method: 'crm.api.invite_by_email', args: { emails: 'user@example.com', role: 'Sales User' } }) ``` -------------------------------- ### Get Filterable Fields for CRM Deal Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Fetches fields that can be used to filter CRM Deal documents. This helps in constructing filter UIs. ```javascript response = frappe.call({ 'method': 'crm.api.doc.get_filterable_fields', 'args': { 'doctype': 'CRM Deal' } }) ``` -------------------------------- ### get_lead_activities Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/activities-api.md Get activity stream for a Lead document. This function retrieves all activities, calls, notes, tasks, and attachments associated with a specific Lead. ```APIDOC ## get_lead_activities(name: str) ### Description Get activity stream for a Lead document. Includes all modifications, communications, comments, linked calls with notes/tasks, and attachments. ### Method GET ### Endpoint /crm/api/activities/get_lead_activities ### Parameters #### Query Parameters - **name** (str) - Required - Lead name ### Response #### Success Response (200) - **activities** (list) - List of activities - **calls** (list) - List of calls - **notes** (list) - List of notes - **tasks** (list) - List of tasks - **attachments** (list) - List of attachments ### Throws - **frappe.PermissionError** if user lacks read permission on Lead ``` -------------------------------- ### Enable Debug Mode Source: https://github.com/frappe/crm/blob/develop/_autodocs/configuration.md Sets a trace point to enable debug output within the Frappe framework. ```python frappe.set_trace() ``` -------------------------------- ### get_deal_activities Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/activities-api.md Get activity stream for a Deal document. This function retrieves all activities, calls, notes, tasks, and attachments associated with a specific Deal. ```APIDOC ## get_deal_activities(name: str) ### Description Get activity stream for a Deal document. If Deal is converted from a Lead, includes the Lead's activities in the history. Activities include document versions, comments, communications, and attachments. ### Method GET ### Endpoint /crm/api/activities/get_deal_activities ### Parameters #### Query Parameters - **name** (str) - Required - Deal name ### Response #### Success Response (200) - **activities** (list) - List of activities - **calls** (list) - List of calls - **notes** (list) - List of notes - **tasks** (list) - List of tasks - **attachments** (list) - List of attachments ### Throws - **frappe.PermissionError** if user lacks read permission on Deal ``` -------------------------------- ### Activity Object: Creation Type Source: https://github.com/frappe/crm/blob/develop/_autodocs/types.md Specific structure for 'creation' activity type, detailing what was created and by whom. ```python { 'activity_type': 'creation', 'data': str, # "created this lead" or "converted the lead to this deal" 'creation': datetime, 'owner': str } ``` -------------------------------- ### Get Dashboard Data Source: https://github.com/frappe/crm/blob/develop/_autodocs/INDEX.md Fetch aggregated dashboard analytics for a specified date range. This helps in monitoring sales performance and other key metrics. ```python frappe.call({ method: 'crm.api.dashboard.get_dashboard', args: { from_date: '2024-01-01', to_date: '2024-01-31' } }) ``` -------------------------------- ### CRM Module Initialization Source: https://github.com/frappe/crm/blob/develop/_autodocs/configuration.md Defines the version and title for the CRM module. This is typically found in the module's __init__.py file. ```python __version__ = "2.0.0-dev" __title__ = "Frappe CRM" ``` -------------------------------- ### create_new Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/contact-api.md Adds a new email or phone entry to a contact. If this is the first entry of that type, sets it as primary. ```APIDOC ## create_new ### Description Add a new email or phone number to a contact. ### Method POST ### Endpoint /api/method/crm.api.contact.create_new ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **contact** (str) - Required - Contact document name - **field** (str) - Required - Field type: "email" or "mobile_no" (or "phone") - **value** (str) - Required - Email address or phone number ### Request Example ```json { "jsonrpc": "2.0", "method": "call", "params": { "contact": "CONT-001", "field": "email", "value": "newemail@example.com" }, "params": { "method": "crm.api.contact.create_new" } } ``` ### Response #### Success Response (200) - **message** (bool) - True on success #### Response Example ```json { "message": true } ``` ``` -------------------------------- ### Get CRM Dashboard Metrics Source: https://github.com/frappe/crm/blob/develop/_autodocs/00-START-HERE.md Fetch dashboard metrics for a specified date range. Detailed documentation for dashboard APIs is available in `api-reference/dashboard-api.md`. ```python frappe.call({ 'method': 'crm.api.dashboard.get_dashboard', 'args': { 'from_date': '2024-01-01', 'to_date': '2024-01-31' } }) ``` -------------------------------- ### Invite New Users to CRM Source: https://github.com/frappe/crm/blob/develop/_autodocs/README.md Send invitations to new users via email, assigning them a specific role within the CRM. Use this for onboarding new team members. ```python response = frappe.call({ 'method': 'crm.api.invite_by_email', 'args': { 'emails': 'user@example.com;user2@example.com', 'role': 'Sales User' } }) ``` -------------------------------- ### get_dashboard() Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/dashboard-api.md Fetches the complete dashboard layout with all configured charts and their data for a specified date range and user. Sales Users see their own data, while Managers can view data for any user. ```APIDOC ## get_dashboard(from_date: str | None = None, to_date: str | None = None, user: str | None = None) ### Description Get the complete dashboard layout with all configured charts and metrics. ### Method GET ### Endpoint /api/method/crm.api.dashboard.get_dashboard ### Parameters #### Query Parameters - **from_date** (str) - Optional - Start date (YYYY-MM-DD); defaults to first day of current month - **to_date** (str) - Optional - End date (YYYY-MM-DD); defaults to last day of current month - **user** (str) - Optional - User to get data for; Sales Users get their own data only ### Request Example ```javascript const response = await frappe.call({ method: 'crm.api.dashboard.get_dashboard', args: { from_date: '2024-01-01', to_date: '2024-01-31' } }); response.message.forEach(item => { console.log(item.name); console.log(item.data); }); ``` ### Response #### Success Response (200) - **name** (str) - chart identifier - **data** (dict) - chart data, populated dynamically ### Requires Roles Sales User, Sales Manager, or System Manager ``` -------------------------------- ### Check Login Status in JavaScript Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/auth-session-api.md Verify if a user is logged in from the frontend. If the user is 'Guest', they are redirected to the login page. ```javascript // Check if logged in if (frappe.session.user === 'Guest') { // Not logged in, redirect to login window.location.href = '/login'; } ``` -------------------------------- ### Invite Users by Email Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/core-api.md Invites users to CRM by providing a comma/semicolon-separated list of email addresses and assigning a role. It returns a breakdown of invited, existing, and previously invited users. ```python @frappe.whitelist() def invite_by_email(emails: str, role: str) -> dict ``` ```javascript response = frappe.call({ 'method': 'crm.api.invite_by_email', 'args': { 'emails': 'user1@example.com;user2@example.com', 'role': 'Sales User' }, 'callback': function(r) { console.log(r.message.to_invite); // newly invited console.log(r.message.existing_members); // already users console.log(r.message.existing_invites); // already invited } }) ``` -------------------------------- ### Get Groupable Fields for CRM Lead Source: https://github.com/frappe/crm/blob/develop/_autodocs/api-reference/doc-api.md Retrieves fields suitable for grouping CRM Lead records. Useful for creating aggregated views or reports. ```javascript response = frappe.call({ 'method': 'crm.api.doc.get_group_by_fields', 'args': { 'doctype': 'CRM Lead' } }) ```