Code components
Location: [Main Menu] > Application Management > Application Design > [Any Application] > [Any Process] > Process Design > Code Components
Python code is provided here to help users directly operate OMFLOW functions through "code components", which will be introduced one by one below:
billing
#import
from omflow.syscom.tools import OmData
#Declare a process object
api_path = 'incident-managment'
inc_flow_obj = OmData(api_path)
#Fill in the form information (not necessary, depending on process requirements)
inc_flow_obj.setFormData('formitm_1', 'Apache service exception')
inc_flow_obj.setFormData('formitm_2', 'red')
inc_flow_obj.setFormData('formitm_3', '1')
#Fill in process variables (not necessary, depending on process requirements)
inc_flow_obj.setFlowVariable('message', 'success')
inc_flow_obj.setFlowVariable('password', '1234567')
#Send bill
user_id = '1' #User ID
files = None #files
result = inc_flow_obj.create(user_id, files)
#Get the response
data_no = result['data_no'] #Single number
status = result['status'] #status True/False
message = result['message'] #Error message, if the order is successfully placed, it will be an empty string.
Push orders
#import
from omflow.syscom.tools import OmData
#Declare a process object
api_path = 'incident-managment'
inc_flow_obj = OmData(api_path)
#Fill in the form information (not necessary, depending on process requirements)
inc_flow_obj.setFormData('formitm_1', 'Apache service exception')
inc_flow_obj.setFormData('formitm_2', 'red')
inc_flow_obj.setFormData('formitm_3', '1')
#pusher
data_id = '345' #Data number (can be obtained through the list)
user_id = '1' #User ID
files = None #files
result = inc_flow_obj.update(data_id, user_id, files)
#Get the response
data_no = result['data_no'] #Single number
status = result['status'] #status True/False
message = result['message'] #Error message, if the order is successfully pushed, it will be an empty string.
List
#import
from omflow.syscom.tools import OmData
#Declare a process object
api_path = 'incident-managment'
inc_flow_obj = OmData(api_path)
#list
search_conditions = [
{
'column':'history',
'condition':'=',
'value':False
}, #Query conditions, query non-historical data
{
'column':'running',
'condition':'=',
'value':False
}, #Query conditions, query non-executing data
{
'column':'error',
'condition':'=',
'value':False
}, #Query conditions, query non-abnormal data
]
search_columns = [
'data_no',
'formitm_1'
] #Get the field, get the order number and field 1
exclude_conditions = [
{
'column':'closed',
'condition':'=',
'value':True
}
] #Exclusion conditions, exclude closed order data
order_columns = ['-data_no'] #Use single number reverse sorting
limit = 0 #Get all data (if the value is 100, it means getting the first 100 data)
start = 0 #Start from the first piece of information
result = inc_flow_obj.list(search_conditions, search_columns, exclude_conditions, order_columns, limit, start)
#Get the response
#For detailed examples of return, please refer to REST API Introduction>Query Form
Delete order
#import
from omflow.syscom.tools import OmData
#Declare a process object
api_path = 'incident-managment'
inc_flow_obj = OmData(api_path)
#deleteorder
data_no_list = [] #Single number array
result = inc_flow_obj.delete(data_no_list)
#Get the response
status = result['status'] #status True/False
message = result['message'] #Error message, if the order is successfully pushed, it will be empty.
##Advanced order promotion
This method will not use data_id to push orders, but will query based on the conditions given by the user. After querying, push orders according to subsequent settings.
#import
from omflow.syscom.tools import OmData
#Declare a process object
api_path = 'incident-managment'
inc_flow_obj = OmData(api_path)
#Fill in the form information (not necessary, depending on process requirements)
inc_flow_obj.setFormData('formitm_1', 'Apache service exception')
inc_flow_obj.setFormData('formitm_2', 'red')
inc_flow_obj.setFormData('formitm_3', '1')
#pusher
condition = {} #query condition
'''
condition can accept two data types (list/dict)
Scenario 1: Query orders with order number equal to 5 and advance
List writing method:
condition = []
con = {'column':'data_no','condition':'=','value':5}
condition.append(con)
How to write dict:
condition = {'data_no':5}
Scenario 2: Query orders with order numbers greater than 5 and push them forward
List writing method:
condition = []
con = {'column':'data_no','condition':'>','value':5}
condition.append(con)
How to write dict:
condition = {'data_no__gt':5}
Scenario 3: Query orders with order numbers greater than 5 and the value of an input field equal to test and advance them simultaneously
List writing method:
condition = []
con1 = {'column':'data_no','condition':'>','value':5}
condition.append(con1)
con2 = {'column':'formitm_1','condition':'=','value':'test'}
condition.append(con2)
How to write dict:
condition = {'data_no__gt':5, 'formitm_1':'test'}
'''
user_id = '1' #User ID
files = None #files
update_duplicate = False #When the data returned by the conditional query is plural, whether to advance all of them. If not, all will not be advanced and a failure message will be returned.
update_duplicate_interval = 0 #When the data to be pushed is multiple, the interval between each push (seconds)
wait_time_max = 0 #When the number of data returned by the query is 0, re-query n times. After n queries are all 0, an error message will be returned.
wait_time_seconds = 0 #Interval time (seconds) between each re-query
result = inc_flow_obj.advanced_update(condition, user_id, files, update_duplicate, update_duplicate_interval, wait_time_seconds, wait_time_max)
#Get the response
status = result['status'] #status True/False
message = result['message'] #Return message. Data_id of successful order push or failure message.
Create user
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Fill in user information (required)
username = 'a12345'
token = 'aA!123456'
nick_name ='Wang Xiaoming'
email = 'a12345@gmail.com'
#Fill in user information (optional)
#The following fields can be filled in
#birthday, gender, phone1, phone2, company, default_group, ad_no, extension_no
other_param_dict = {}
other_param_dict['ad_no'] = '001234'
other_param_dict['phone1'] = '0911111111'
#Create user
result = user_obj.create(username, token, nick_name, email, other_param_dict)
#Get the response
user_id = result['user_id'] #user id
status = result['status'] #status True/False
message = result['message'] #Error message, if the order is successfully placed, it will be an empty string.
Update user
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Select the user to be modified (required, choose one of user_id and username)
user_id = None
username=None
#Change password (optional)
token = 'aA!123456'
#Fill in the user field to be updated (optional)
#The following fields can be filled in
#email, birthday, gender, phone1, phone2, company, default_group, ad_no, extension_no
other_param_dict = {}
other_param_dict['phone1'] = '0911111111'
#Update user
result = user_obj.update(user_id, username, token, other_param_dict)
#If result = 'success', it means success. If it fails, an error message will be returned.
Query user list
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Query conditions (the following is an example, please modify it according to actual needs)
search_conditions = [
{
'column':'gender',
'condition':'=',
'value':'female'
}, #Query conditions, query female users
]
search_columns = [
'username',
'email'
] #Get fields, get account and mailbox
exclude_conditions = [
{
'column':'is_active',
'condition':'=',
'value':False
}
] #Exclusion criteria, exclude disabled users
order_columns = ['-username'] #Use account reverse sorting
limit = 0 #Get all data (if the value is 100, it means getting the first 100 data)
start = 0 #Start from the first piece of information
#Query user
result = user_obj.list(search_conditions, search_columns, exclude_conditions, order_columns, limit, start)
#Get the response
#For detailed examples of return, please refer to REST API Introduction>User
Query a single user
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Query conditions (required, choose one of the following three)
user_id = None
username=None
nick_name = None
#Fill in the user field to be queried
#The following fields can be filled in
#id, username, nick_name, email, birthday, gender, phone1, phone2, company, default_group, ad_no, extension_no
#If left blank, it means querying all fields
user_attr = []
#Query user
result = user_obj.load(user_id, username, nick_name, user_attr)
#Get the reply (please obtain the information according to the query field)
#resultThe data structure is as follows
{
'id':123,
'username':'12312',
'nick_name':'Wang Xiaoming',
'email':'123@gamil.com', #The above fields will vary according to the user_attr variable
'groups':[], #groups and roles are fixed responses, regardless of whether user_attr is filled in or not.
'roles':[], #groups returns the department id array of the user's department, roles returns the role id array of the user's role
}
Query user email list
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Fill in the user id to be queried (array)
user_id_list = []
#Query multiple users’ emails
result = user_obj.listEmail(user_id_list)
#resultThe data format is as follows
['aaa@gmail.com','bbb@gmail.com','ccc@gmail.com','ddd@gmail.com']
Delete user
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Fill in the user account to be queried (array)
username_list = []
#Delete user
result = user_obj.delete(username_list)
#result If equal to an empty string, it means the deletion is successful. If any text message is returned, it means an error message.
User joins department
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Select user (required)
user_id = None
#Fill in the department id array to be added (required)
group_id_list = []
#User joins department
result = user_obj.addtoGroup(user_id, group_id_list)
#result is boolean, True represents success, False represents failure
User moves out of department
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Select user (required)
user_id = None
#Fill in the department ID array to be moved out (required)
group_id_list = []
#User moved out of department
result = user_obj.removefromGroup(user_id, group_id_list)
#result is boolean, True represents success, False represents failure
Find people through organization chart
※ Divided into querying from organization chart or querying from department structure
#import
from omflow.syscom.tools import User
#Declare a process object
user_obj = User()
#Select user (required)
user_id = None
#Department code (optional), specify which department to start the query from, if not filled in, the query will start from the user's default department
group_no=None
#Fill in the job title or job code or authority and responsibility name of the person you want to query (required, choose one of the following three)
position_name = None
position_no = None
response_name = None
#Select to query from the organization chart or department structure. If dept_search is False, please fill in the name of the organization chart
dept_search=False
org_name=''
#Query organization chart
result = user_obj.getPosition(user_id, group_no, org_name, position_name, position_no, responsibilitie_name, dept_search)
#Get the response
manager_user_id = result.get('user_id','')
manager_group_no = result.get('group_no','')
Create department
#import
from omflow.syscom.tools import Group
#Declare an object of a department (role)
group_obj = Group()
#Fill in the information (required)
group_name = 'test' #Department name
is_role = False #Fill in True as the role and False as the department
#Fill in the information (optional)
parent_group_id = None #Parent department id, role cannot be filled in
description = '' #Description field
group_no = '' #Department code
order = 0 #Department sorting, the smaller the number, the higher the sorting, please fill in an integer (can be negative)
#Create department
result = group_obj.create(parent_group_id, group_name, description, group_no, is_role, order)
#Get the response
group_id = result['group_id'] #Department/role id
status = result['status'] #status True/False
message = result['message'] #Error message, if the order is successfully placed, it will be an empty string.
Get department information
#import
from omflow.syscom.tools import Group
#Declare an object of a department (role)
group_id = ''
group_no = ''
group_name = ''
#Department id/Department code/Department name Please choose one of the three to fill in the value
group_obj = Group(group_id, group_no, group_name)
#Read department information
result = group_obj.load()
#Get the response
group_id = result.get('id','') #Department id
display_name = result.get('display_name','') #Department name
parent_group_id = result.get('parent_group_id','') #Parent department id
description = result.get('description','') #Description
group_no = result.get('group_no','') #Department code
group_user_list = result.get('group_user_list','') #The user IDs under this department
permissions = result.get('permissions','') #The permissions of this role are returned as an empty array when querying the department.
order = result.get('order ','') #Department sorting
Add users
#import
from omflow.syscom.tools import Group
#Declare an object of a department (role)
group_id = ''
group_no = ''
group_name = ''
#Department id/Department code/Department name Please choose one of the three to fill in the value
group_obj = Group(group_id, group_no, group_name)
#Fill in the user id list
user_id_list = []
#Department joins users, result is boolean, True represents success, False represents failure
result = group_obj.addUsers(user_id_list)
Remove user
#import
from omflow.syscom.tools import Group
#Declare an object of a department (role)
group_id = ''
group_no = ''
group_name = ''
#Department id/Department code/Department name Please choose one of the three to fill in the value
group_obj = Group(group_id, group_no, group_name)
#Fill in the user id list
user_id_list = []
#Department moves out users, result is boolean, True represents success, False represents failure
result = group_obj.removeUsers(user_id_list)
Find people through organization chart
※ Divided into querying from organization chart or querying from department structure
#import
from omflow.syscom.tools import Group
#Declare an object of a department (role)
group_id = ''
group_no = ''
group_name = ''
#Department id/Department code/Department name Please choose one of the three to fill in the value
group_obj = Group(group_id, group_no, group_name)
#Fill in the job title or job code or authority and responsibility name of the person you want to query (required, choose one of the following three)
position_name = None
position_no = None
response_name = None
#Select to query from the organization chart or department structure. If dept_search is False, please fill in the name of the organization chart
org_name=''
dept_search=False
#Query organization chart
result = group_obj.getPosition(org_name='', position_name=None, position_no=None, responsibilitie_name=None, dept_search=False)
#Get the response
manager_user_id = result.get('user_id','')
manager_group_no = result.get('group_no','')
Query department duties, rights and responsibilities
#import
from omflow.syscom.tools import Group
#Declare a department object
group_id = ''
group_no = ''
group_name = ''
#Department id/Department code/Department name Please choose one of the three to fill in the value
group_obj = Group(group_id, group_no, group_name)
#Get the response
result = group_obj.loadGroupJobRole()
An example of the returned data is as follows:
[
{
"job_role_id": <data number>,
"position_id": <position number>,
"position_no": <position code>,
"position_name": <position name>,
"user_id": <user number>,
"nick_name": <user display name>,
"is_active": <whether the user is active>,
"responsibility": <rights and responsibilities>,
"data_index": <sort>
},...........
]
Update department duties and responsibilities
#import
from omflow.syscom.tools import Group
#Declare a department object
group_id = ''
group_no = ''
group_name = ''
#Department id/Department code/Department name Please choose one of the three to fill in the value
group_obj = Group(group_id, group_no, group_name)
job_role_list = [
{
'job_role_id': <data number>, #Fill in when modifying old data
'position_no': <position code>,
'user_id': <user number>,
'responsibility': <responsibilities>,
'data_index': <sort>
},...........
]
result = group_obj.updateGroupJobRole(job_role_list)
#Get the response
status = result['status'] #status success/update error
message = result['message'] #Error message, empty string if execution is successful
Get organization chart information
#import
from omflow.syscom.tools import OrgChart
#Declare an organization chart object
org_name = ''
org_config_id = ''
#Organization Chart Name/Organization Chart Number, please choose one and fill in the value
org_obj = OrgChart(org_name, org_config_id)
#Read organization chart information
result = org_obj.load()
An example of the returned data is as follows:
{
"org_name": <organization chart name>,
"value": [{
"org_id": <organization element number>,
"group_no": <organization component code>,
"group_name": <organization element name>,
"parent_group_no": <parent organization component code>,
"order": <Organization component order>,
"host_user": <host>, #user number
"host": <whether it is hosted>, #True/False
"is_host": <whether it belongs to the hosting organization>, #True/False
"job_role": [{
"job_role_id": <data number>,
"position_id": <position number>,
"position_no": <position code>,
"position_name": <position name>,
"user_id": <user number>,
"nick_name": <user display name>,
"is_active": <whether the user is active>, #True/False
"responsibility": <rights and responsibilities>,
"data_index": <sort>
}
],
"sub_item": <hosting organization>,
"parent_group_name": <parent organization element name>
},...........
],
"org_approver": {
"group": <reviewer department number>,
"user": <reviewer user number>
},
"is_search_dept": <When the organization chart cannot be queried, query the department structure>, #True/False
"is_sub": <Is it a hosted organization chart>, #True/False
"parent_chart_name": <main chart name>,
"uid": <uid>,
"pending_status": <Whether the hosted organization chart is in review status>, #True/False
"host_user": <host>,
"org_config_id": <organization chart number>
}
Update/Add organization chart
#import
from omflow.syscom.tools import OrgChart
#Declare an organization chart object
org_obj = OrgChart()
org_chart_dict = {
'org_name': <organization chart name>,
'value': [{
'org_id': <Organization component number>, #Fill in when modifying old data
'group_no': <organization component code>,
'group_name': <organization element name>,
'parent_group_no': <parent organization component code>,
'order': <Organization component order>,
'host_user': <host>, #user number
'host': <whether it is hosted>, #True/False
'is_host': <whether it belongs to the hosting organization>, #True/False
'job_role': [{
'job_role_id': <data number>, #Fill in when modifying old data
'position_no': <position code>,
'user_id': <user number>,
'responsibility': <responsibilities>,
'data_index': <sort>
}
]
},...........
],
'org_approver': {
'group': <Reviewer department number>,
'user': <moderator user number>
},
'is_search_dept': <When the organization chart cannot be queried, query the department structure>, #True/False
'is_sub': <Is it a hosted organization chart>, #True/False
'uid': <uid>,
'org_config_id': <organization chart number> #Fill in when modifying old information
}
#Update/add organizational chart information
result = org_obj.update(org_chart_dict)
#Get the response
status = result['status'] #status success/update error
message = result['message'] #Error message, empty string if execution is successful
op_result = result['result'] #Execution result, empty string if execution is successful
Delete organization chart
#import
from omflow.syscom.tools import OrgChart
#Declare an organization chart object
org_obj = OrgChart()
org_config_id_list = [<organization chart number>,.....]
#Delete organization chart
result = org_obj.delete(org_config_id_list )
#Get the response
status = result['status'] #status success/delete error
message = result['message'] #Error message, empty string if execution is successful
op_result = result['result'] #Execution result, empty string if execution is successful
※ If you want to delete a hosted image, you should update the main image information to unhost it, not this method.
Last updated