Skip to main content

erpnext@1.0.0

create(doctype, data)
deleteRecord(doctype, name)
getCount(doctype, filters)
getList(doctype, options)
read(doctype, name)
update(doctype, name, data)

This adaptor exports the following from common:

dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
lastReferenceValue()
merge()
sourceValue()

Functions

create

create(doctype, data) ⇒ Operation

Create a document in ERPNext. Returns the complete created document with all fields.

ParamTypeDescription
doctypestringThe doctype to create (e.g., "Customer", "Sales Order")
dataobjectThe document data as JSON

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the ERPNext server (excluding the body)
referencesAn array of all previous data objects used in the Job

Example: Create a customer record

create('Customer', {
customer_name: 'Acme Corporation',
customer_type: 'Company'
});

Example: Create with data from state

create('Sales Order', $.orderData);

Example: Create an item with multiple fields

create('Item', {
item_code: 'ITEM-001',
item_name: 'Sample Product',
item_group: 'Products',
stock_uom: 'Nos'
});

deleteRecord

deleteRecord(doctype, name) ⇒ Operation

Delete a document from ERPNext

ParamTypeDescription
doctypestringThe doctype to delete from (e.g., "Customer", "Sales Order")
namestringThe document name/ID to delete

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the ERPNext server (excluding the body)
referencesAn array of all previous data objects used in the Job

Example: Delete a customer

deleteRecord('Customer', 'CUST-00001');

Example: Delete using state data

deleteRecord('Sales Order', $.data.order_id);

Example: Delete a draft document

deleteRecord('Quotation', 'QTN-00001');

getCount

getCount(doctype, filters) ⇒ Operation

Get count of documents matching filters

ParamTypeDescription
doctypestringThe doctype to count (e.g., "Customer", "Sales Order")
filtersobjectOptional filters to apply (e.g., { status: 'Open' })

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the ERPNext server (excluding the body)
referencesAn array of all previous data objects used in the Job

Example: Count all customers

getCount('Customer');

Example: Count with filters

getCount('Sales Order', { status: 'Open' });

Example: Count from state data

getCount('Item', { item_group: $.data.group_name });

getList

getList(doctype, options) ⇒ Operation

Get a list of documents from ERPNext with filtering, field selection, and pagination

ParamTypeDescription
doctypestringThe doctype to query (e.g., "Customer", "Sales Order")
optionsListOptionsOptional query configuration. See Frappe Database API for supported options.

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the ERPNext server (excluding the body)
referencesAn array of all previous data objects used in the Job

Example: Get all customers

getList('Customer');

Example: Get customers with filters

getList('Customer', {
filters: { customer_type: 'Company' },
fields: ['name', 'customer_name', 'territory']
});

Example: Get with pagination

getList('Sales Order', {
filters: { status: 'Draft' },
limit: 50,
offset: 0,
orderBy: 'creation desc'
});

Example: Get specific fields only

getList('Item', {
fields: ['item_code', 'item_name', 'standard_rate'],
filters: { item_group: 'Products' },
limit: 100
});

read

read(doctype, name) ⇒ Operation

Read a document from ERPNext by name/ID. Returns the complete document with all fields. Note: For field selection, use getList() with filters instead.

ParamTypeDescription
doctypestringThe doctype to read from (e.g., "Customer", "Sales Order")
namestringThe document name/ID to read

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the ERPNext server (excluding the body)
referencesAn array of all previous data objects used in the Job

Example: Read a customer by name

read('Customer', 'CUST-00001');

Example: Read from state data

read('Item', $.data.item_code);

Example: Read a sales order

read('Sales Order', $.orderId);

update

update(doctype, name, data) ⇒ Operation

Update a document in ERPNext

ParamTypeDescription
doctypestringThe doctype to update (e.g., "Customer", "Sales Order")
namestringThe document name/ID to update
dataobjectThe fields to update as JSON

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the ERPNext server (excluding the body)
referencesAn array of all previous data objects used in the Job

Example: Update a customer's details

update('Customer', 'CUST-00001', {
customer_name: 'Updated Corp Name',
mobile_no: '+1234567890'
});

Example: Update using state data

update('Sales Order', $.data.order_id, {
status: 'Confirmed'
});

Example: Update multiple fields

update('Item', 'ITEM-001', {
item_name: 'Updated Product Name',
standard_rate: 150.00,
description: 'Updated description'
});

Interfaces

ListOptions

Options object for list operations

See: Frappe Database API

Properties

NameTypeDescription
filtersobjectFilters to apply to the query (e.g., { status: 'Open' }).
fieldsArray.<string>Array of field names to return (e.g., ['name', 'status']).
limitnumberMaximum number of records to return. Defaults to 1000.
offsetnumberNumber of records to skip. Defaults to 0.
orderBystringField to sort by with direction (e.g., 'creation desc').