📁
ActiveBooks
  • ActiveBooks Documentation
  • Importing Data in ActiveBooks
    • Downloading Backups
    • Chart of Accounts Importer
    • Data Export
    • Data Import Tools
  • Printing
    • Printing and Branding
    • Print Settings
    • Print Format
    • Print Format Builder
    • Print Style
    • Print Headings
    • Address Template
    • Terms And Conditions
    • Cheque Print Template
    • Custom Translations
    • Raw Printing
  • Workflows
    • Workflows
    • Workflow Actions
    • Workflow State
    • Assignment Rule
    • Email
      • Email
      • Email Domain
      • Email Account
      • Untitled
      • Untitled
      • Untitled
      • Untitled
      • Untitled
      • Untitled
      • Untitled
      • Untitled
      • Untitled
      • Email
  • Email
    • Users and Permissions
      • Basic setup of ActiveBooks
        • Setting up Company in ActiveBooks
        • Setting up Taxes in ActiveBooks
        • Setting up Company's Sales Goals
        • Global Defaults in ActiveBooks
        • System Settings in ActiveBooks
        • Letter Head
      • Adding Users
      • Users and Permissions
      • Role and Role Profile
      • Role Based Permissions
      • User Permissions
      • Role Permission for Page and Report
      • Sharing
      • Limited User
      • Administrator
    • Email
    • Email Domain
    • Email Account
    • Email Inbox
    • Email Template
    • Sending Email from any Document
    • Linking Emails to Documents
    • Email Digest
    • Auto Email Reports
    • SMS Settings
    • Notification
    • Document Follow
    • Email Dropbox
  • System Configuration
    • Settings
    • Show or Hide Modules
    • Naming Series
    • Session Defaults
    • Bulk Renaming of Records
    • Bulk Update
    • Milestone Tracking
    • Auto Repeat
    • Domain settings
    • Energy Point System
  • Data Privacy
    • Personal Data Download
    • Personal Data Deletion
  • Articles
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
    • Untitled
  • Using ActiveBooks
    • Articles
      • Checking Link Between Documents
      • Access Log
      • Duplicate Records
      • To-Do Auto Creation
      • Document Versioning
      • Deleting and Restoring Documents
      • Bulk Rename
      • Renaming Documents
      • Tree Master Renaming
      • Letter Head in the Report
      • Copy Pasting Multiple Records From Excel
      • Adding Attachments to Outgoing Messages
    • Collaboration Tools
      • Assignment
      • Tags
      • Kanban Board
      • Filter by
      • Save Filter
      • Search Filter
      • Collaborating Around Forms
      • Delete Company Transactions
    • Introduction
      • Tools
        • To Do
        • Notes
        • Video
        • Calendar
        • Chat
        • Dashboard
        • Global Search
        • Desktop
  • Automation
    • Automation
    • Assignment Rule
    • Milestone Tracking
    • Auto Repeat
    • Event Streaming
  • Accounts
    • Introduction
      • Setup and Opening
        • Accounting Entries
        • Accounts Settings
        • Company Setup
        • Chart of Accounts
        • Opening Balance in Accounts
        • Cost Center
        • Distributed Cost Center
        • Fiscal Year
        • Accounting Period
        • Finance Book
        • Accounting Dimensions
        • Accounting Dimensions Filters
        • Bank
        • Bank Account
      • Billing
        • Sales Invoice
        • Purchase Invoice
        • Inter Company Invoices
        • Credit Note
        • Debit Note
        • Credit Limit
      • Taxes
        • Item Tax Template
        • Tax Withholding Category
        • Tax Rule
        • Tax Category
      • Pricing
        • Pricing Rule
        • Promotional Scheme
        • Exchange Rate Revaluation
        • Currency Exchange
        • Currency
      • Retail Operations
        • Point of Sale Profile
        • Point of Sale
        • Cashier Closing
      • Tools
        • Bank Reconciliation
        • Payment Reconciliation
        • Period Closing Voucher
        • Payment Order
        • ActiveBooks to QuickBooks Migrator
        • Process Statement of Accounts
      • Accounting Reports
        • Accounting Reports
      • Advanced
        • Multi Currency Accounting
        • Deferred Revenue
        • Deferred Expense
        • Process Deferred Accounting
        • Bank Guarantee
          • Budgeting
        • Loyalty Program
        • Auto Repeat
        • Invoice Discounting
      • Subscription
        • Subscription
        • Subscription Plan
        • Subscription Settings
      • Shareholder Management
        • Share Holder
        • Share Transfer
        • Share Reports
      • Articles
        • Articles
        • Freeze Accounting Entries
        • Post Dated Cheque Entry
        • Adjust Withhold Amount in the Payment Entry
        • Bulk Payment Entry
        • Difference Entry
        • Changing Parent Account
        • Withdrawing Salary from Owner's Equity Account
        • Common Receivable Account
        • Freeze an Account
        • Round of Account Validation Message
        • Purchase Tax or Charges Categories
        • Types in Sales and Purchase Tax Template
        • Manage Foreign Exchange Difference
        • Recurring Orders and Invoices
        • Delivery from Sales Invoice
        • Exchange Rate Field Frozen
        • Fiscal Year Creation
        • How To Customize Cash Flow Report
        • Immutable Ledger In ActiveBooks
        • Purchase Invoice - Account Type Error
        • Fixing Fiscal Year Error
        • Stock and Accounting Module Integration
        • Merging Accounts
  • Stock
    • Basics
      • Introduction
      • Warehouse
      • Item
      • Opening Stock
      • Accounting Of Inventory Stock
      • Price Lists
      • Stock Settings
    • Item Variants
      • Item Variants
      • Item Attribute
    • Setup
      • Item Price
      • Item Group
      • Unit of Measure (UoM)
      • Manufacturer
    • Stock Transactions
      • Material Request
      • Purchase Receipt
      • Delivery Note
      • Stock Entry
      • Packing Slip
      • Shipment
      • Retaining Sample Stock
      • Landed Cost Voucher
      • Pick List
      • Putaway Rule
    • Serial and Batch Number
      • Serial Number
      • Batch
      • Installation Note
    • Tools
      • Quality Inspection
      • Stock Reconciliation
      • Quick Stock Balance
    • Return
      • Sales Return
      • Purchase Return
    • Advanced
      • Delivery Trip
      • Projected Quantity
      • Perpetual Inventory
    • Stock Reports
      • Stock Ledger Report
      • Stock Level Report
      • BOM Explorer
      • Stock Value and Account Value Comparison Report
      • Articles
        • Allow Over Delivery/Billing
        • Auto Creation of Material Request
        • Delivery Note Negative Stock Error
        • Stock Entry Purpose
        • Purpose of Stock Received but not Billed
        • Item Valuation Methods and Transactions
        • Maintain Stock field Frozen in the Item master
        • Managing Rejected Finished Goods Items
        • Return Rejected Items
        • Track Items Using Barcode
        • Item Valuation Fifo And Moving Average
        • Item Codification
        • Serial No. Naming
        • Opening Stock Balance Entry for Serialized and Batch Item
        • Managing Batch wise Inventory
        • Sales Return Management
        • Managing Fractions in UOM
        • Repack Entry
        • Material Transfer from Delivery Note and Purchase Receipt
        • Mode of Payment
        • Migrate To Perpetual Inventory
        • Depreciation Entry
  • CRM
    • Introduction to CRM
    • Sales
      • Lead
      • Opportunity
      • Customer
      • Contact
      • Address
      • Appointment
    • Reports
      • CRM Reports
    • Setup
      • Lead Source
      • Opportunity Type
      • Sales Stage
      • Sales Person
      • Customer Group
      • Email Group
      • Contract
      • Appointment Booking Settings
    • Marketing
      • Campaign
      • Email Campaign
      • Newsletter
      • LinkedIn Settings
      • Twitter Settings
      • Social Media Post
    • Articles
      • Automate Lead Creation
      • CRM Analytics
      • Difference between Lead, Contact and Customer
  • Selling
    • Selling
    • Quotation
    • Sales Order
    • Sales Partner
    • Brand
    • Blanket Order
    • Territory
    • Setup
      • Selling Settings
      • Product Bundle
      • Sales Person Target Allocation
      • Sales Taxes and Charges Template
      • Shipping Rule
      • Party Specific Item
    • Articles
      • Sales Persons in the Sales Transactions
      • Request for Raw Material from Sales Order
      • Applying a Discount
      • Selling in Different Unit (UoM)
      • Adding Margin
      • Amending Sales Order after Submit
      • Drop Ship
      • Calculate Incentive for Sales Team
      • Shipping Rule
      • Close Sales Order
      • Taxes and Charges
      • Print Settings
      • Payment Terms
    • Selling Reports
      • Sales Reports
  • Buying
    • Buying
      • Request for Quotation
      • Purchase Order
      • Purchase Taxes and Charges Template
      • Supplier
      • Supplier Quotation
      • Supplier Scorecard
    • Setup
      • Buying Settings
      • Supplier Groups
    • Articles
      • Maintaining Supplier's Item Code in the Item Master
      • Purchasing in Different Unit (UoM)
      • Amending Purchase Order after Submit
      • Procurement Tracker Report
  • HR
    • Employee
      • Employee
      • Employment Type
      • Branch
      • Department
      • Designation
      • Employee Grade
      • Employee Group
      • Employee Health Insurance
    • Attendance
      • Attendance
      • Employee Attendance Tool
      • Attendance Request
      • Upload Attendance
      • Auto Attendance
    • Leave Management
      • Leaves
      • Holiday List
      • Leave Type
      • Leave Period
      • Leave Policy
      • Leave Policy Assignment
      • Leave Allocation
      • Leave Application
      • Compensatory Leave Request
      • Leave Encashment
      • Leave Block List
      • Leave Ledger Entry
    • Recruitment
      • Recruitment
      • Employee Referal
      • Staffing Plan
      • Job Opening
      • Job Applicant
      • Job Offer
      • Appointment Letter
    • Training
      • Training Program
      • Training Event
      • Training Result
      • Training Feedback
    • Employee Life Cycle
      • Employee Life Cycle Management
      • Employee Onboarding
      • Employee Promotion
      • Employee Seperation
      • Employee Transfer
      • Employee Skill Map
    • Payroll
      • Payroll Setup
      • Payroll Management
      • Payroll Period
      • Income Tax Slab
      • Salary Component
      • Salary Structure
      • Salary Structure Assignment
      • Salary Slip
      • Payroll Entry
      • Additional Salary
      • Retention Bonus
      • Employee Incentive
    • Employee Tax and Benefits
      • Setting Up Income tax Deduction
      • Employee Tax Exemption Declaration
      • Employee Tax Exemption Proof Submission
      • Employee Other Income
      • Employee Benefit Application
      • Employee Benefit Claim
    • Travel and Expense Claim
      • Travel Request
      • Employee Advance
      • Expense Claim
    • Gratuity
      • Gratuity
      • Gratuity Rule
    • Loans
      • Loan Type
      • Loan Application
      • Loan
    • Shift Management
      • Shift Management
    • Fleet Management
      • Fleet Management
      • Vehicle
      • Vehicle Log
    • Setup
      • Human Resource Setup
      • HR Settings
      • Daily Work Summary Group
    • Reports
      • Human Resources Reports
    • Articles
      • Articles
      • Leave Calculation in Salary Slip
      • Workdays Calculation in the Salary Slip
    • Performance
      • Appraisal
  • Projects
    • Project
      • Project and Managing Expenses
      • Salary Slip from Timesheet
      • Activity Type
      • Project Template
      • Timesheet
      • Projects
      • Introduction to the Project Module
      • Project Profitability
      • Project Reports
      • Project Type
      • Project Update
      • Project from Customer Portal
      • Activity Cost
      • Project Costing
      • Project
      • Tasks
      • Project Views
      • Sales Invoice from Timesheet
      • Delayed Tasks Summary
      • Project Profitability Report
    • Articles
      • Make A Colorful Gantt Chart
Powered by GitBook
On this page
  • 1. Prerequisites
  • 2. How to set up Event Streaming
  • 3. Features

Was this helpful?

  1. Automation

Event Streaming

Event Streaming enables inter site communications between two or more sites. You can subscribe to Document Types and stream Documents between different sites.

  • For Example: Consider you have more than one Company hosted on different sites, one among them is the main site where you want to do ledger posting and on other sites, the Sales Invoices are generated.

  • You can use Event Streaming in this case.

  • For this, your child company sites can subscribe to the main company site for Item, Customer, and Supplier Document Types.

  • The main Company in turn can subscribe to the child companies for Sales Invoices.

To access Event Streaming, go to: Tools > Event Streaming

1. Prerequisites

  • Before creating an Event Producer, a common user needs to be created on both the sites which will be used to access the site and will act as an Event Subscriber.

  • Make sure the user is a System Manager and has the necessary permissions for creation, updation, and deletion of the subscribed DocTypes.

2. How to set up Event Streaming

Let's take two sites for explaining the process. http://testsite:8000 (Consumer site) and http://testsite_producer:8000 (Producer site).

2.1 Obtain the Event Subscriber's keys from the Producer Site

  1. On http://testsiteproducer:8000 (producer site), go to the User list.

  2. Open the user document you are going to use as an Event Subscriber.

  3. Scroll down to the section labelled "API Access".

  4. In that section, generate keys for the user by clicking on Generate Keys button.

  5. You will get a prompt with the user secret, copy the user secret and save it with you. It will also generate an API key.

2.2 Generate Keys for the Event Subscriber on the Consumer Site

  1. On http://test_site:8000 (consumer site), go to the User list and follow the same process specified in the previous step.

  1. The site which you want to subscribe to, is called as the Event Producer. Create an Event Producer document for the site you wish to get the updates from.

  2. On http://test_site:8000 (consumer site), go to Home > Automation > Event Streaming > Event Producer.

  3. Enter the URL of the site you want to subscribe to (in this case http://testsiteproducer:8000), in the Producer URL field.

  4. Add all the Document Types you want to subscribe to, in the Event Producer Document Types table.

  5. If you want to have the created documents with the same name as it is on the remote Event Producer site, check the 'Use Same Name' checkbox in the table against the required Document Type.

  6. Set the Event Subscriber field to the user that will be used to create the documents fetched from the Event Producer. You need to create the same user both ways, i.e. on the Event Consumer as well as the Event Producer site before creating the Event Producer.

  7. Paste the API key and API Secret you generated in the first step (2.1) in the API key and API secret fields respectively.

  8. Save.

  9. After saving, an Event Consumer is created on the producer site (http://testsiteproducer:8000). The keys of the user on the consumer site are automatically copied to the Event Consumer document on the producer site in this process.

Note: If at all the API Secret is changed for the users on any of these sites, you will have to manually update the keys in the Event Producer as well as the Event Consumer on both the sites.

  1. After the Event Producer has been created, an Event Consumer automatically gets created on the producer site. By default, all the Subscribed Document Types have the status as 'Pending'. In order to enable the Event Consumer to consume the documents of these Document Types, their Status needs to be updated to 'Approved'.

  2. Go to: Home > Automation > Event Streaming > Event Consumer.

  3. Once you open the Event Consumer document you will see all the Document Types that the consumer has subscribed to. Change the status from 'Pending' to 'Approved' for all the Document Types that you want to approve to be consumed. You can change the status to 'Rejected' if you do not want the documents of that Document Type to be consumed.

  4. Save.

Note: Document updates for Subscribed Document Types won't be synced unless they are Approved.

If you have some places where internet connectivity is low, for example, a store in a remote area where sales invoices are generated and you want to sync these invoices from the store to the hosted account, you could setup offline syncing using the following steps:

  1. You need to have hosted account with your company set up.

  2. Now create an Event Producer on the hosted account and set the producer URL to the URL of your local account.

  3. Add whatever doctypes you want to sync in the Event Producer Document Types child table.

  4. Approve the doctypes.

As an Event Consumer, if you wish to unsubscribe from the updates for any doctypes you had previously subscribed to, check unsubscribe against the doctype. You will not receive any more updates from the producer site for that particular doctype once you have unsubscribed.

"Event Update Log" logs every create, update, and delete action for documents that have consumers on the Event Producer site. In order to view the Event Update Log:

Go to: Home > Automation > Event Streaming > Event Update Log.

  • For 'Create' type the Update Type, Document Type, Document Name and the entire document (as JSON) is logged.

  • For 'Update' type the Update Type, Document Type, Document Name and the updated data (difference between the previous state and current state of the document) is logged.

  • For 'Delete' type only the Update Type, Document Type, and Document Name is logged.

Like the Update Log, Event Sync Log logs every document synced from the Event Producer on the Event Consumer site. In order to view the Event Sync Log:

Go to: Home > Automation > Event Streaming > Event Sync Log.

A successfully synced event generates a log document with:

  • Update Type: Create, Update or Delete

  • Status: Sync Status

  • DocType

  • Event Producer: The site URL from where the document was created

  • Document Name

  • Remote Document Name: If 'Use Same Name' is unchecked

  • Use Same Name

  • Data: The document data as JSON

A failed event generates a log doc with the above fields along with:

Certain Document Types have dependencies. For example, before syncing a Sales Invoice, the Item and Customer need to be present in the current site. So, Item and Customer are dependencies for Sales Invoice. Event Streaming handles this by on-demand dependency syncing. Whenever any document is to be synced, it first checks whether the document has any dependencies (Link fields, Dynamic Link fields, Child Table fields, etc.). If that dependency is not fullfilled i.e. the dependent document (eg: Item) is not present on your consumer site, it will be synced first and then the Sales Invoice will be synced.

Check the 'Use Same Name' checkbox to let the documents have same name on both Event Producer and Event Consumer sites. If this is not checked, then the document will be created using the naming conventions of the current site.

Note: For Document Types that have naming series, it is advised to keep the 'Use Same Name' checkbox unchecked, to prevent naming conflicts. If this is unchecked, the Documents are created by following the naming conventions on the current site and the 'Remote Site Name' and 'Remote Document Name' custom fields are set in the synced document to store the Event Producer site URL and the document name on the remote site respectively.

If you want to stream documents between an ERPNext instance and another Frappe app for a particular Document Type with same or different structures, or if field names are different in both the sites, you can use Event Streaming with Mapping Configuration.

For this you need to first set up a Document Type Mapping.

To access Document Type Mapping, go to:

Home > Automation > Event Streaming > Document Type Mapping.

3.6.1 Mapping for DocTypes with similar structure

  • Mapping Name: Give a unique name to the mapping

  • Local Document Type: The Document Type in your current site

  • Remote Document Type: The Document Type on the Event Producer site which you want to sync

In the Field Mapping child table:

  • Local Fieldname: The fieldname in the Local Document type of your current site.

  • Remote Fieldname: The fieldname in the Remote Document type of the Event Producer site which you want to map to the Local Fieldname. During the sync, the value of the remote fieldname gets copied to the local fieldname.

3.6.2 Default value for some field

If your field is not mapped to any other remote fieldname and you always want the field to have the same value, set the set the same in the default value field. Event if you have set the remote fieldname, in case during the sync, remote field's value is not found and if the "Default Value" has been specified, it will be set.

3.6.3 Mapping for DocTypes having child tables

If the field you are trying to map is a child table, you need to create another Document Type Mapping for the child table fields.

  • Mapping Type: Select the Mapping Type as Child Table.

  • Mapping: Select the Document Type Mapping document you created for the child table.

3.6.4 Mapping for DocTypes having dependencies (Link, Dynamic Link fields)

If the DocTypes you are trying to map have any kind of dependencies like Link or Dynamic Link fields, you need to set up another Document Type Mapping for syncing the dependencies.

For example, let's assume that the local doctype is Opportunity and the remote doctype is ActiveBooks Opportunity. The field party_name (Link field for DocType Lead) in Opportunity is mapped to full_name (Data field) in ActiveBooks Opportunity. During the sync, this Lead has to be created for the main Opportunity to sync. So you need to set up a mapping for this Link Field too.

  • Mapping Type: In this case, the Mapping Type is Document.

  • Mapping: Select the mapping you just created.

  • Remote Value Filters: You need to specify the filters that will fetch the exact remote document to be mapped. Like in this case, the remote DocType is ERPNext Opportunity which can be uniquely fetched using name, phone number and country.

The format is:

{ "remote fieldname": "field or expression from where we will get the value for that fieldname"}

If you want to fetch the value from somewhere, start the expression with eval:

Like in this case it is: eval:frappe.db.get_value('Global Defaults', None, 'country')

Lastly, enable the 'Has Mapping' option in the Event Configuration child table in Event Producer against the required Document Type and select the Document Type Mapping you just created.

If you are in scenario when you do not want to send over all the documents in a doctype over to the consumer, you can specify the conditions for them.

For example, if you would like to emit only those Note documents that are public, you can specify them within the Producer/Consumer document.

If a document satisfies a condition down the line in its lifetime, all the old Event Update Logs are synced to the consumer

Let's consider another example. You want to sync only those Sales Invoices that are submitted. You can specify doc.docstatus == 1 as the condition. The invoices will not be synced until they are submitted.

For each update log, you can see its Consumers within the Update Log document.

If you need more fine control over the conditions, you can hook up a custom function. Your function will be executed with parameters consumer, doc & update_log. For example, you want to sync only those Notes that are odd

def is_odd_note(consumer, doc, update_log):
    return frappe.db.sql("""
        SELECT
            COUNT(*)
        FROM `tabNote`
        WHERE creation <= %(creation)s
    """, { "creation": doc.creation })[0][0] % 2 != 0

Then, you could specify the condition:

cmd: my_custom_app.note.is_odd_note

PreviousAuto RepeatNextAccounts

Last updated 3 years ago

Was this helpful?

2.3 Create an Event Producer on the Consumer Site

2.4 Approve Event Consumer on the Event Producer site

2.5 Offline access with single site

Set up an ERPNext local instance. You can refer for local setup.

3. Features

3.1 Unsubscribe from the updates

3.2 Event Update Log

3.3 Event Sync Log

Event Sync Log

Error: The error because of which the document was not synced.

Resync Button: It also provides a 'Resync' button in order to resync the failed event.

3.4 Dependency Syncing

For example: Sales Invoice syncing with Item dependency:

3.5 Naming Configuration

Use Same Name Config
Subscribed Document

3.6 Mapping Configuration

Document Type Mapping
Child Table Mapping Link
Child Table Mapping Link
Child Table Mapping Link
Lead Dependency Creation
Document Mapping Type
Mapping Configuration

3.6 Conditional Events Configuration

Child Table Mapping Link
this guide
Event Sync Log
Event Synced
Event Failed
Event Dependency