DocBits- IDP for Infor ERP
HomeAppStatusAPI
🇺🇸 English
🇺🇸 English
  • Overview and Basics
    • DocBits
      • Key Features of DocBits
    • Architecture
      • DocBits Infor on Premise Customer
      • Certifications
    • Infor Infrastructure
    • Release Notes
      • Testing Availability on Sandbox
    • FAQ
      • General Information
      • Document Processing
        • Table Extraction Troubleshoot
      • Infor LN (LN Integration)
        • Export Error: "Error Exporting Document to LN. Status Code: 500"
          • not found in direct debit
          • Request validation; Attr. 'ReceiptLine', Value " " : the value must be numeric.
      • Infor M3 (M3 Integration)
        • Costing elements are not properly configured. Please ask your admin to configure it.
      • Mandatory PDP/PPF Channels – PEPPOL as Transport Only for France’s 2026 E-Invoicing
  • End User and Partner Section
    • End User Section
      • Dashboard
        • Dashboard Tools
        • Document Merging
        • Document Status
        • Filtering Documents
        • Overview of Uploaded Documents
        • Task Counter
        • Validated Extracted Fields
        • Document Flow
        • Troubleshooting
        • Keyboard Shortcuts
      • Tasks
      • Advance Shipment Dashboard
      • Purchase Order Dashboard
      • Invoice Dashboard
      • Shipment Order Dashboard
      • User Configuration Options
      • AI Table
        • AI Table Tags
      • Validation Screen
        • Fuzzy Data
        • QR Codes
        • Keyboard Shortcuts
      • Purpose and Use
      • Purchase Order Matching
        • Automatic Purchase Order Data Matching
        • Supplier Item Number Map
        • Keyboard Shortcuts
      • Accounting for Cost Invoice and Indirect Sales
      • How to Import Documents
        • FTP
        • Manual Import
        • Webhook
        • Email
          • IMAP
          • OAuth Office365
      • Technical Support in DocBits
        • Create a ticket
        • Help Icons
      • Course
        • Introduction
        • Dashboard
        • Validated Documents
        • AI Table
        • Master PO Matching with DocBits
      • Our Document Priority System
      • Supplier Portal
        • Supplier Registration
        • Supplier Satuts
      • Ressources and Support
        • User Support
    • Partner Section
      • Invoice Automation Testing with DocBits
  • Administration and Setup
    • Settings
      • Global Settings
        • Company Information
          • Defining App Color in Company Settings
        • Groups, Users and Permissions
          • Users
            • Modifying User Details
            • Admin Privileges
          • Sub-Organizations
            • How to create a Sub-Organization
          • Groups and Permissions
            • Purpose and Use
            • Adding/Editing Groups
            • Activating Permissions
            • Access Control
            • Troubleshooting
        • Integration
          • API Key
          • API Calls and Examples
          • API Key Management
          • Configuring Single Sign-On (SSO)
            • Infor SSO Configuration
              • V1
              • V2
              • Azure SSO
          • Identity Service Provider Configuration
          • Best practices
          • Troubleshooting Common Issues
        • Document Types
          • Purpose and Scope
          • Adding/Editing Document Types
          • Activation
          • Customization Options
          • Best Practice
          • Troubleshooting
          • Layout Manager
            • Purpose and Use
            • Navigating the Layout Manager
            • Configuring Field Properties
            • Using the Template Preview
            • Save and apply changes
            • Best practices
            • Troubleshooting
          • Document Sub Types
          • Creating a new Sub Type
          • Configure subtypes
          • Using Actions
          • Best Practices
          • Table Columns
            • Purpose and Use
            • Adding a new Column
            • Editing and deleting columns
            • Best practices
            • Troubleshooting
          • Fields
            • Purpose and Use
            • Adding and Editing Fields
            • Configuring Field Properties
            • Setting Validation and Match Score
            • Best practices
            • Troubleshooting
            • New Fields with Charges
          • Model Training
            • Purpose and Use: Model Training
            • Import Data: Model Training
            • Manage training data
            • Testing the model
            • Best practices
            • Troubleshooting
          • Regex
            • Purpose and use
            • Creating a Regex Pattern
            • Editing and Saving Regex Patterns
            • Best practices
            • Troubleshooting
          • Script
          • Script Activation and Management
          • Testing Scripts
          • Purpose and Use
          • Creating and Editing Scripts
          • Best Practices
          • Troubleshooting
          • e-docs
            • Currently Supported E-Invoice Standards
              • Roadmap
            • E-Invoice examples
              • XRechnung 1.2
              • XRechnung 2.0
              • XRechnung 2.1
              • XRechnung 2.2
              • XRechnung 2.3
              • XRechnung 3.0
              • XRechnung Cross Industry Invoice
              • FacturX
            • EDI
              • Purpose and Use
              • Setting Up EDI Templates
                • EDI Structure descriptor
              • Using the XSLT Editor
                • EDI Videos
              • Previewing EDI Messages
              • Best Practices
              • Troubleshooting
              • EDI 810 (Invoice) Mapping
              • EDI 855 (Purchase Order Acknowledgement) Mapping
              • EDI 850 (Purchase Order) Mapping
              • EDI 856 (Advance Shipment Notice) Mapping
            • XRechnung
              • Standard Preview
              • Mapping XRechnung in DocBits
                • TOML Export
            • Peppol BIS Billing 3.0
              • Transformation file and Mapping
            • Faktura
            • ZUGFeRD 1.0, 2.1 and 2.3
            • eSLOG 1.6 and 2.0
          • More Settings
            • Purpose and use
            • Best practices
            • Troubleshooting
            • Duplicate Document Handling
            • Approval Stamp
            • Approval History
            • Supplier Item Number Map - Admin Documentation
            • Purchase order tolerance settings / Additional purchase order tolerance
            • Purchase order disable statuses
            • PO Table in Layout Builder
            • Auto check for PO updates
            • Calculate PO unit price
            • Export not matched PO lines
        • Email Notification
          • Configuring Notifications
          • Managing Notifications
          • Best Practice
          • Troubleshooting
        • Dashboard
          • Customizing Filters
      • Document Processing
        • Documents Expiry
        • Import
          • Test: Multi Email Import and Handling Tests
          • Test: Email Import and Handling Tests
          • Test: FTP Import Connection
          • Test: File Import 1
        • Rule Manager
          • TransactionConfig Pro Template
            • Case 1, 2, 3: Quantity and Unit Price Within Tolerance
            • Case 4, 5: Quantity Within Tolerance, Unit Price Outside Tolerance (Approved)
            • Case 15: Charge Line - Charge Per Unit Outside Tolerance (Rejected)
            • Case 14: Header Charge - Charge Per Unit Outside Tolerance (Approved)
            • Case 12, 13: Header Charge - Charge Per Unit Within Tolerance
            • Charge Per Unit Outside Tolerance (Rejected)
            • Case 14: Charge Line - Charge Per Unit Outside Tolerance (Approved)
            • Charge Per Unit Within Tolerance
            • Case 11b: Quantity Outside Tolerance (Positive Rejected), Unit Price Outside Tolerance (Rejected)
            • Case 10b: Quantity Outside Tolerance (Negative Rejected), Unit Price Outside Tolerance (Rejected)
            • Case 8b, 9b: Quantity Outside Tolerance (Approved), Unit Price Outside Tolerance (Approved)
            • Case 11a: Quantity Outside Tolerance (Positive Rejected), Unit Price Within Tolerance
            • Case 10a: Quantity Outside Tolerance (Negative Rejected), Unit Price Within Tolerance
            • Case 7: Quantity Within Tolerance, Unit Price Outside Tolerance (Positive Rejected)
            • Case 6: Quantity Within Tolerance, Unit Price Outside Negative Tolerance (Rejected)
            • Case 8a, 9a: Quantity Outside Tolerance (Approved), Unit Price Within Tolerance
            • Case 15: Header Charge - Charge Per Unit Outside Tolerance (Rejected)
            • Tax Lines
        • Ocr Settings
        • Classification And Extraction
          • Table extraction for costing element
          • Auto extract tax code
        • Master Data Lookup
        • List Of Values
        • Export
        • Module
          • Annotation Mode
          • Approval Before Export
          • Doc Scan
          • Doc Script
          • IDM ACL Updater
          • Inbound Emails
          • Swiss QR Code
          • Auto Export if PO Matched 100%
          • Export Dashboard Data
          • How to Create Database Access for a Specific Organization User
        • Decision Trees
      • Log Settings
        • Task Management
        • Data Synchronization
      • API Licenses
      • Supplier Setting
        • Supplier General Settings
        • Editing Email Templates
        • Supplier Layout
        • Export Configuration for Supplier Portal for M3
        • Supplier Permissions
      • Cache Management
    • Workflow
      • When
        • Card description
        • Document Type Operation
        • Document Type One of
      • And
        • Compare with Purchase Order
          • Combined Price of Quantity Difference
          • Unit Price Combined with Fields
          • Promised Delivery Date on Purchase Order
          • Order Data in Order Confirmation
          • Confirmed Delivery Date
          • Compare Order Confirmation with Purchase order
          • Tax in document field
          • Any / All Quantity
          • Compare Total Charges
          • Out of Tolerance Unit Price
          • Any / All Unit Price is
          • Item Id on Purchase Order
          • Supplier on Invoice
          • Order Type of Purchase Order
        • Document Field
          • Checkbox is checked
          • Field is
          • Text in Field
          • Compare two Fields with Tolerance
          • Compare two Fields
          • If Country in Field
          • Docfield is
          • Compare Field with tolerances
          • If Country in Field is One of
        • Date & Time
          • Date or Time
          • Today
        • Document
          • Document Type Operation one of
          • Document Operator for Sub-Organizations
          • Document Type
        • Logic
          • Continue with a chance
          • Send HTTPS Request
          • Module active
          • Quoted Item Price
          • Decision Table has Returns
        • Status
          • Single Document Status Condition
          • Document Status Condition List
        • Table
          • Any Value of
          • All Value of
          • Compare values in table
          • Compare In
          • Item Receiving Method
          • Items Have Shelf Life
        • Assignee
          • Assigned User Condition
          • Single Assigned User Condition
          • Assigned Group Condition
          • Single Assigned User Condition
      • Then
        • Document Field
          • Set to
          • Set Checkbox to
          • Invert Checkbox
        • Document
          • Approve the Document
          • Reject the Document
        • Status
          • Change Status to
        • Export
          • Export with Export Configuration
          • Start Export
          • Export with alternate Export
        • Task
          • Create a New Task and assign it to the User
          • Create a New Task and assign it to the Recipient
          • Create a New Task and assign it to the group
          • Create a New Task and assign it to the User in Document Field
          • Assign a Task with Title
          • Create a New Task and assign it to Procurement Group
          • Assign to Procurement Group and Create a Task/Notification
          • Assign Document and Create Task/Notification for Group
          • Assign Document and Create Task/Notification for User
          • Assign Document and Create Task/Notification
        • Table
          • Change Entries with
          • Calculate Columns with
          • Calculate in
        • Assignee
          • Assign user from field
          • Assign document to User
          • Assign document to recipient
          • Assign document to the sub organization
          • Assign document to matching sub organization
          • Assign to group
          • Assign document to procurement group
          • Assign document to
          • Assign Sequentially to User
          • Assign Sequentially to Procurement Group
          • Assign Sequentially to Groups
          • Assign Sequentially to User/Group
        • Action
          • Call Api
          • Run Workflow
          • Send HTTPS request to
          • AI Calculation for Cost Increase Surcharges
      • Workflow Example: Conditional Export Trigger
      • Workflow Documentation
      • Standard Workflow
        • Above Max Amount
        • Cost Invoice - Export
        • Less than Max Amount
        • Purchase Invoice - 2nd Approval Quantity Export
        • Purchase Invoice - 2nd Approval Quantity
        • Purchase Invoice - 2nd Approval Unit Price Export
        • Purchase Invoice - 2nd Approval Unit Price
      • Material Ordering and Processing Workflow
    • Setup
      • Document Types
        • EDI Data Transformation Process
        • Layout Builder
        • Origin Layouts
        • Regex Manager
      • Document Training
        • Training Header Fields
        • Training Line Fields/Table Training
          • Adding New Columns
          • Defining Tables and Columns
          • Advanced Settings
          • Grouping Function
          • Manual Row Selection
          • Mapping Columns
          • Improving Table Extraction with Regex
          • Save and Delete Rules
      • Testing
        • PO Matching
        • Auto Accounting
          • LN
          • M3
      • Supplier Portal
      • WatchDog Installation
    • Report Page
  • Infor Integration and Configuration
    • Importing Master Data
      • Field Mappings
      • LN
        • Auto Accounting
        • Suppliers and Purchase Orders
          • Purchase Order - FAQ
          • Verifying the Logistic Company Setting for Goods Receipt Discrepancies
        • Tax Codes
      • M3
        • Auto Accounting
        • Suppliers and Purchase Orders
        • How to import all suppliers
        • Table Extraction for costing Element
      • Custom Master Data
    • Exporting in DocBits
      • Export Module
      • Alternate Export
    • Exporting to INFOR
      • Creating a BOD Mapping File
      • Creating an IDM Mapping File
      • Creating an ION API Endpoint
      • Creating an ION API File
      • Export to M3 Mapping (API)
      • Exporting to IDM
      • Stream for Cloud Customers
      • Order Confirmation
      • Document Export Mapping
      • M3
        • Example Export M3
        • Handling Charges with Infor M3
        • M3 Configuration
      • LN
        • Example Export LN
          • Configuring the Default Tax Country for Export LN
        • Export Tax Codes to LN
        • LN Configuration
  • Advanced functions and tools
    • Scripting in DocBits
      • Calculating Total Charges Script for Docbits
      • Calculating Total Charges Script for Docbits
      • Delete lines with empty quantity and amount
      • Formatting Export Certificate Reference Numbers Script for Docbits
      • Functions
      • Generating Extended Invoice Numbers Script for Docbits
      • Generating Extended Invoice Numbers Script for Docbits
      • USD as Default Currency
    • Course
      • A Step-by-Step Guide
      • Connect DocBits with Infor SSO
      • Create your Custom App in Infor OS
      • Infor OS with DocBits API Integration
      • M3 Export
      • Sync Flex Dimensions: Infor to DocBits
    • Postman for DocBits
    • Automated Tests Results
      • Email Import
    • SQL Access
    • Importing Supplier and Purchase Order Data into DocBits from CSV Files
    • PowerBI
      • SQL Access
        • Custom classification document
        • Field
        • Document table column
        • Email template
        • Ephesoft PO matching
        • Fellow kv table column rule
        • Group cache
        • Preferences
        • Sales order
        • API credentials
        • public.document_log
        • Auto accounting
        • Document status trigger
        • Document type
        • Documents
        • Document type attributes
        • Document Report
        • Electronic document extraction attributes
        • Lookup field configuration
        • Lookup table
        • Batch instance
        • Document extracted data
        • Document Import log
        • Lookup Configuration
        • Sub document type
        • Document Status alert
        • Inbound Emails
        • Chat Log
        • REST API Lookup Configurations
        • FTP Import Configurations
        • Purchase Order line
        • Receive delivery line
        • Document Script activation status
        • Field validation rules
        • Custom_classification_document_label
        • Training data
        • Tfidf preferences
        • Additional charge costing element
        • PO match tolerance
        • Auto test document
        • Custom classification tag
        • Supplier address
        • Organisation document type
        • Sub Organisation Cache
Powered by GitBook
On this page
  • Functional Documentation
  • Functions
  • set_field_value()
  • set_date_value()
  • set_amount_value()
  • get_field_value()
  • create_new_field()
  • delete_field()
  • set_is_required()
  • set_force_validation()
  • set_field_as_invalid()
  • set_field_attribute()
  • is_supplier_valid()
  • get_document_content()
  • update_document_status_with_doc_id()
  • get_lov_values()
  • format_decimal_to_locale()
  • compare_values()
  • create_document_task()
  • set_document_sub_org_id()
  • get_user_by_id()
  • get_group_by_id()
  • get_user_by_email()
  • add_table_column()
  • get_column_value()
  • set_column_value()
  • set_column_date_value()
  • set_column_amount_value()
  • delete_tables()
  • restore_tables()
  • remove_rows_from_table()
  • remove_all_rows_except_one_from_table()
  • Python Built-in Functions
  • String Class Functions
  • Functions from the Python Math Module
  • Regular Expression Function
  • External Functions
  • Date and Time Functions

Was this helpful?

Edit on GitHub
Export as PDF
  1. Advanced functions and tools
  2. Scripting in DocBits

Functions

Functional Documentation

This module contains functions for manipulating document data and performing various operations related to document fields.

Functions

set_field_value()

Sets the value of a field in the document data.

po_number = get_field_value(fields_dict, 'purchase_order', None)
if not po_number:
    po_number = ''
    
if po_number:
    set_field_value(fields_dict, "invoice_sub_type", 'Purchase Invoice')
else:
    set_field_value(fields_dict, "invoice_sub_type", 'Cost Invoice')

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to set

value*

any

The value to set for the field

remove_link (optional)

bool

Remove the "coords" key from the field.

set_date_value()

Sets the value of a date field in the document data.

invoice_date = get_field_value(document_data, 'invoice_date', None)
    
if not document_json.get("script_executed", False):
    if invoice_date:
        set_date_value(document_data, "accounting_date", invoice_date)
        document_json["script_executed"] = True

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to set

value*

string

The date value to set in ISO format (e.g., "2020-12-31").

add_days (optional)

int

Add additional days to the given date Default is 0

skip_weekend (optional)

bool

Skips the date if it falls on the weekend Default is False

remove link (optional)

bool

Remove the "coords" key from the field.

exclude_final_days (optional)

either string or int

Specifies the days to exclude (0-6 or Sunday to Saturday)

set_amount_value()

Sets the value of an amount field in the document data.

total_amount = get_field_value(document_data, "net_amount")
lines_total = 0.0
set_amount_value(document_data, "net_amount",str(lines_total))

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to set

value*

string

The value to set for the field (pass a number as string e.g., "123456"

remove link (optional)

bool

Remove the "coords" key from the field.

get_field_value()

Gets the value of a field from the document data.

total_amount = get_field_value(document_data, "net_amount")
lines_total = 0.0
set_amount_value(document_data, "net_amount", str(lines_total))

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to set

default_value (optional)

any

Returns default_value if no field value is found Default is None

is_clean (optional)

bool

Converts the value to uppercase and removes any extra spaces Default is False

Returns:

  • Value of the specified field

create_new_field()

Creates a new field with the specified name and value.

currency = get_field_value(document_data, 'currency', None)

if not currency:
    if 'currency' not in fields_dict:
        new_field = create_new_field('currency','')
        fields_dict['currency'] = new_field
        document_json['fields'].append(new_field)
    set_field_value(document_data, "currency", "USD")

Parameters:

Name
Type
Description

field_name*

str

The document data containing field information

value (optional)

any

The initial value for the field Default is ""

Returns:

  • Dictionary of the new created field

delete_field()

Deletes a field from the document data

field_amount = get_field_value(document_data, field_name)
    if not field_amount:
        delete_field(document_data, fields_dict, field_name)
    else:
        field_amount = float(field_amount)
        if field_amount == 0:
            delete_field(document_data, fields_dict, field_name)

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to delete

Returns:

  • Document_data as json and as dict after field got deleted

set_is_required()

Sets the 'is_required' attribute of a field in the document data.

net_amount = get_field_value(document_data, "net_amount", None)
if net_amount:
    set_is_required(document_data, "tax_country", True)
    set_is_required(document_data, "tax_code_without_country", True)

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to set

value*

bool

The value to set for the field

set_force_validation()

Sets the 'force_validation' attribute of a field in the document data.

if supplier_id in supplier_to_check:
    set_force_validation(document_data, 'purchase_order', True, reset_validation=reset_validation)

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to set

value*

bool

The value to set for the field

reset_validation (optional)

bool

Sets the "is_validated" attribute to the specified value Default is False

set_field_as_invalid()

Marks a field in the validation screen as invalid and highlights it.

if not document_date:
    set_field_as_invalid(document_data, "document_date", "Es ist kein Datum vorhanden", "INVALID_VALUE")

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to mark as invalid

message*

string

The validation message for the field

code (optional)

string

Error code for the validation

Default is None

set_field_attribute()

Sets a custom attribute of a field in the document data.

if purchase_order:
    if po_supplier_id != invoice_supplier_id:
        set_field_as_invalid(document_data, "supplier_name", "Supplier is different from PO supplier")
    else:
        set_field_attribute(document_data, "supplier_name", "is_valid", True)
        set_field_attribute(document_data, "supplier_name", "validation_message","")

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

field_name*

string

The name of the field to set

attribute_name*

string

The name of the attribute to set

value*

any

The value to set for the attribute

is_supplier_valid()

Checks if a supplier is valid based on the provided criteria.

bool = is_supplier_valid(user, {"name": "Supplier Inc."})

Parameters:

Name
Type
Description

user*

UserAuthentication

The authenticated user

filter_data_json*

json

Filter criteria for validating the supplier

sub_org_id (optional)

string

Optional sub-organization ID for filtering Default is None

Returns:

  • True, if the user is valid

  • False if the user isn’t valid

get_document_content()

Decodes document data and returns it as a string.

document_content = get_document_content(doc)
if document_content:
    document_content = document_content.lower()

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

Returns:

  • Document data as a string.

update_document_status_with_doc_id()

Updates the status of a document with a specific ID to the given status.

genehmigung_user_1 = get_field_value(document_data, 'genehmigung_user_1', None)

if genehmigung_user_1 != "LEER":
    update_document_status_with_doc_id(document_json['doc_id'], user, document_json['org_id'], "validated_pending_approval")

Parameters:

Name
Type
Description

doc_id*

string

The ID of the document to update

user*

either user ID or UserAuthentication object

The user performing the update

org_id*

string

The ID of the organization to which the document belongs

status*

string

The new status of the document

message (optional)

string

Optional message associated with the status update Default is None

doc_classification_class (optional)

string

Optional document classification class Default is None

get_lov_values()

Gets the LOV values from a specific org_id and key.

reverse_charge_to_check = get_lov_values(org_id, 'Kosten', return_type="list_of_values")

Parameters:

Name
Type
Description

org_id*

string

The ID of the organization to which the document belongs

key*

string

The key of the required List Of Values

return_type (optional)

string

The type in which the data should be returned Default is 'list_of_objects'

sub_org_id (optional)

string

Optional sub-organization ID for filtering Default is None

language_code (optional)

string

This parameter sets the language in which the values will be returned. It accepts language codes, such as "en" for English or "fr" for French. Default is ""

Returns:

  • LOV-Values as a list of objects or as a list.

format_decimal_to_locale()

Formats a decimal value to en_US.UTF-8 format.

standard_value = "{0:.2f}".format(total)
formatted_value = format_decimal_to_locale(
    standard_value, document_json['amount_format_locale']
)

Parameters:

Name
Type
Description

value*

float, decimal.Decimal, str

The ID of the organization to which the document belongs

to_locale (optional)

string

The type in which the data should be returned Default is 'en_US.UTF-8'

max_decimal_places (optional)

int

Optional sub-organization ID for filtering Default is 4

min_decimal_places (optional)

int

The minimum of decimal places which should be considered Default is 2

  • value: The value which should be formatted.

  • to_locale (optional): The format in which the value gets transformed.

  • max_decimal_places (optional): The maximum of decimal places which should be considered.

  • min_decimal_places (optional): The minimum of decimal places which should be considered.

Returns:

  • The formatted value.

compare_values()

Compares two values for equality, handling various data types.

result = compare_values(10, "10")

Parameters:

Name
Type
Description

value1*

any

The first value to compare

value2*

any

The second value to compare

Returns:

  • True if the values are equal and False if they differ

create_document_task()

Creates a task, assigns it to a user or group, sets priority, and optionally sends an email.

if not is_task_created:
            create_document_task(user, document_data, "Herkunftsland außerhalb der EU", "Die Gelangensbestätigung kommt von einem Land außerhalb der EU. Bitte das MRN-Dokument anhängen.", "high", 1007, None, False)
            document_data["document_json"]["country_check_task_created"] = True

Parameters:

Name
Type
Description

user*

either user ID or UserAuthentication object

The user performing the update

document_data*

dictionary

The document data containing field information

title*

string

The title of the task

description*

string

The description of the task

priority*

string

The priority of the task

assigned_to_user_id*

int

The id of the user to which the task should assigned to

assigned_to_group_id*

int

The id of the group to which the task should assigned to

send_email*

bool

Determine if an email should be send or not

Returns:

  • Dict which is indicating if the process was successful or not

set_document_sub_org_id()

Sets the sub_org_id of the specified document_data.

if sub_org_id != current_sub_org_id:
    document_data["document_json"]["sub_org_id4"] = sub_org_id
    set_document_sub_org_id(document_data, sub_org_id)

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

sub_org_id*

string

Optional sub-organization ID for filtering

get_user_by_id()

Gets the user with the corresponding user ID.

requester_mail = str(get_user_by_id(str(requester)).email.lower())

Parameters:

Name
Type
Description

user_id*

string

The ID of the user

Returns:

  • The user with the corresponding user ID

get_group_by_id()

Gets the group with the corresponding group ID.

group_name  = str(get_group_by_id(assigned_to_group_id))

Parameters:

Name
Type
Description

group_id*

string

The ID of the group

Returns:

  • The group with the corresponding group ID

get_user_by_email()

Gets the group with the corresponding group ID.

user_name = str(get_user_by_email(email)

Parameters:

Name
Type
Description

email*

any

The email of the user

Returns:

  • The user with the corresponding email

add_table_column()

Adds a column to the specified table.

table = tables_dict.get("ORDER_CONFIRMATION_TABLE")

if table:
    add_table_column(table, "PROMISED_DELIVERY_DATE")

Parameters:

Name
Type
Description

table*

string

The table where the column should be added

col_name*

string

The name of the column

default_value (optional)

any

The initial value for the field

Default is None

get_column_value()

Gets the value of a specified column.

for row in table['rows']:
        unit = get_column_value(row, "UNIT")

Parameters:

Name
Type
Description

row*

string

The row where the value is located

col_name*

string

The name of the column

default_value (optional)

any

The initial value for the field Default is None

is_clean (optional)

bool

Converts the value to uppercase and removes any extra spaces Default is False

Returns

  • Returns the value of the specified column if it exists; otherwise, it returns None

set_column_value()

Sets the value of the specified column. If the column does not exist, it will be created.

supplier_id = get_field_value(document_data, "supplier_id", "")

quote_table = tables_dict["QUOTE_TABLE"]

for row in quote_table.get('rows', []):
    set_column_value(row,"SUPPLIER_ID", supplier_id)

Parameters:

Name
Type
Description

row*

string

The row where the value is located

col_name*

string

The name of the column

value*

any

The value that will be set at the specified location

Returns:

  • True if the change was successful

set_column_date_value()

Sets the date value of a specified column.

set_column_date_value(document_data, row, "DELIVERY_DATE", "2020-12-31", add_days=2)

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

row*

string

The row where the value is located

col_name*

string

The name of the column

value*

string

The date value to set in ISO format (e.g., "2020-12-31")

add_days (optional)

int

Add additional days to the given date Default is 2

skip_weekend (optional)

bool

Skips the date if it falls on the weekend Default is False

exclude_final_days (optional)

either string or int

Specifies the days to exclude (0-6 or Sunday to Saturday)

set_column_amount_value()

  • Convert value to string and set the value for the column

  • Set column content to the value

  • Format value according to the locale

quantity = float(quantity) / 1000
set_column_amount_value(document_data, row, "QUANTITY", str(quantity))

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

row*

string

The row where the value is located

column_name*

string

The name of the column

value*

string

The value to set for the field (pass a number as string e.g., "123456")

delete_tables()

This function deletes the tables from the document data.

delete_tables(document_data)

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

restore_tables()

This function restores the tables in the document data.

restore_tables(document_data)

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

remove_rows_from_table()

Removes rows from the specified table.

count = 1
start = 1
remove_rows_from_table(document_data,"INVOICE_TABLE",count,start) 

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

table_name*

string

The name of the table

count*

int

How many lines should be deleted

start*

int

The starting point

remove_all_rows_except_one_from_table()

Removes all rows except one from the specified table

count = 1
start = 1
remove_rows_from_table(document_data,"INVOICE_TABLE",count,start) 

Parameters:

Name
Type
Description

document_data*

dictionary

The document data containing field information

line_number*

int

The number of the line which should not be removed

Python Built-in Functions

You can also utilize some of the python in-build functions:

  • abs(): Returns the absolute value of a number.

  • len(): Returns the length (number of items) of an object, like a list or string.

  • isinstance(): Checks if an object is an instance of a particular class or type.

  • print(): Prints output to the console.

  • round(): Rounds a floating-point number to a specified number of decimal places.

  • str_to_bool(): Converts a string to a boolean value (True or False).

  • type(): Returns the type of an object.

  • dict(): Creates a dictionary object.

  • list(): Creates a list object.

  • str(): Converts a value to a string.

  • float(): Converts a value to a floating-point number.

  • int(): Converts a value to an integer.

String Class Functions

You can also use these functions specifically for working with strings:

  • lower(): Converts all characters in a string to lowercase.

  • upper(): Converts all characters in a string to uppercase.

  • split(): Splits a string into a list based on a delimiter (e.g., space or comma).

  • startswith(): Checks if a string starts with a specified prefix.

  • endswith(): Checks if a string ends with a specified suffix.

  • strip(): Removes any leading or trailing whitespace from a string.

Functions from the Python Math Module

These functions are part of the math module and are useful for mathematical operations:

  • floor(): Returns the largest integer less than or equal to a given number.

  • ceil(): Returns the smallest integer greater than or equal to a given number.

Regular Expression Function

  • re.search(): Searches for a pattern within a string and returns the first match.

External Functions

Here are some useful functions from external libraries:

Date and Time Functions

You can use the following functions for working with dates and times:

  • strptime(): Converts a string into a datetime object based on a specified format.

  • strftime(): Formats a datetime object into a string based on a specified format.

PreviousFormatting Export Certificate Reference Numbers Script for DocbitsNextGenerating Extended Invoice Numbers Script for Docbits

Last updated 2 months ago

Was this helpful?

For more details, visit the official Python documentation: .

For more information, check out the official Python documentation: .

See more details here: .

deepcopy(): Creates a copy of an object, including nested objects (from the copy module). .

levenshtein_distance(): Calculates the number of edits (insertions, deletions, substitutions) required to change one string into another. This function is available in the .

For more information, check the official documentation: .

Built-in Functions
Math Module Functions
re.search Documentation
Deepcopy Documentation
Jellyfish library
Date and Time Functions