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.
Parameters:
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
set_date_value()
Sets the value of a date field in the document data.
Parameters:
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
set_amount_value()
Sets the value of an amount field in the document data.
Parameters:
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"
get_field_value()
Gets the value of a field from the document data.
Parameters:
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.
Parameters:
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
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
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
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.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
group_id*
string
The ID of the group
Returns:
The group with the corresponding group ID
add_table_column()
Adds a column to the specified table.
Parameters:
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.
Parameters:
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
The value of the specified column
set_column_value()
Sets the value of a specified column.
Parameters:
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.
Parameters:
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
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
Parameters:
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")
remove_rows_from_table()
Removes rows from the specified table.
Parameters:
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
Parameters:
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.
For more details, visit the official Python documentation: Built-in Functions.
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.
For more information, check out the official Python documentation: Math Module Functions.
Regular Expression Function
re.search(): Searches for a pattern within a string and returns the first match.
See more details here: re.search Documentation.
External Functions
Here are some useful functions from external libraries:
deepcopy(): Creates a copy of an object, including nested objects (from the copy module). Deepcopy Documentation.
levenshtein_distance(): Calculates the number of edits (insertions, deletions, substitutions) required to change one string into another. This function is available in the Jellyfish library.
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.
For more information, check the official documentation: Date and Time Functions.
Last updated
Was this helpful?