Functions to insert, update, and delete records to built-in table in a workflow.
$fn.createCase
Register a new record in the $case table.
Arguments
Name Type Description param object Input Object
Property Type Description database string Database with built-in tables status_id string Status ID owner_id string User ID of the next person in charge
Return value
Type Description Promise<{case: Case}> Objects with the case property
Property Type Description case Case Case Object
Sample
const user = await $fn . getCurrentUser ();
const param = {database: ' mydb ' , status_id: ' saved ' , owner_id: user . userId } ;
const obj = await $fn . createCase ( param );
const case_obj = obj . case ;
const case_id = case_obj . case_id ;
$param [ ' case_id ' ] = case_id ;
$fn.updateCase
Updates the $case table with the target case subject to the case_id according to the argument.
Arguments
Name Type Description param object Input object
Property Type Description database string Database with built-in tables case_id string Case ID status_id string Status ID owner_id string User ID of the next person in charge
Return value
Type Description Promise<{case: Case}> Objects with the case property
Property Type Description case Case Case Object
Sample
const selectUser = $ui . wf_combo_field . value ;
let caseId = $ui . case_id_field . value ;
const param = {database: ' mydb ' , case_id: caseId , status_id: ' applying ' , owner_id: selectUser } ;
const obj = await $fn . updateCase ( param );
const case_obj = obj . case ;
const case_id = case_obj . case_id ;
$param [ ' case_id ' ] = case_id ;
$fn.remandCase
Updates the target case according to the arguments subject to case_id for the $case table. The status_id and owner_id of the $case table are updated to the previous status_id and the person in charge from the history in the $case_history table.
Arguments
Name Type Description param object Input Object
Property Type Description database string Database with built-in tables case_id string Case ID
Return value
Type Description Promise<{case: Case}> Objects with the case property
Property Type Description case Case Case Object
Sample
let caseId = $ui . case_id_field . value ;
const param = {database: ' mydb ' , case_id: caseId } ;
const obj = await $fn . remandCase ( param );
const case_obj = obj . case ;
const case_id = case_obj . case_id ;
$param [ ' case_id ' ] = case_id ;
$fn.withdrawCase
Updates the target case according to the argument subject to case_id for the $case table. The owner_id of the $case table is updated with the user who executed $fn.withdrawCase (=sign-in user).
Arguments
Name Type Description param object Input Object
Property Type Description database string Database with built-in tables status_id string Status ID owner_id string User ID of the next person in charge
Return value
Type Description Promise<{case: Case}> Objects with the case property
Property Type Description case Case Case Object
Sample
let caseId = $ui . case_id_field . value ;
const param = {database: ' mydb ' , case_id: caseId , status_id: ' saved ' } ;
const obj = await $fn . withdrawCase ( param );
const case_obj = obj . case ;
const case_id = case_obj . case_id ;
$param [ ' case_id ' ] = case_id ;
$fn.rejectCase
Updates the target case according to the argument subject to case_id for the $case table. The $case table is updated with a blank owner_id.
Arguments
Name Type Description param object Input Object
Property Type Description database string Database with built-in tables case_id string Case ID status_id string Status ID
Return value
Type Description Promise<{case: Case}> Objects with the case property
Property Type Description case Case Case Object
Sample
let caseId = $ui . case_id_field . value ;
const param = {database: ' mydb ' , case_id: caseId , status_id: ' saved ' } ;
const obj = await $fn . rejectCase ( param );
const case_obj = obj . case ;
const case_id = case_obj . case_id ;
$param [ ' case_id ' ] = case_id ;
$fn.getWorkflowDef
Retrieve workflow definition information defined in the Workflow Editor
Arguments
None
Return value
Type Description array[node] Array with objects for each node
Property Type Description node Node Node object
Property Type Description nodeId String Node ID (start | end | any) nodeLabel String Node Label nodeType String Node type (start | status | end | operation) statusUi String Status UI (none | any) operationType String Operation Type (none | create | update | remand | reject) fromStatus String Status ID of the operation source{nodeId} toStatus String Status ID of the operation target{nodeId} nextOwner String Next Owner (none | select_user | current_user)
Sample
* ---------------------------------------------------------------------------------
* SELECT * FROM $case_history;
* ------------------------------------------------------------------------------------
// SQL function to retrieve historical data of case records
const case_history = await caseSelect ();
// Obtain workflow definition information
const def = await $fn . getWorkflowDef ();
// Obtain node labels from workflow definition information
const array = case_history . data . map ( value => {
case_history_id: value . id ,
before_status_label: def . find ( e => e . nodeId === value . before_status_id ) ?. nodeLabel ,
after_status_label: def . find ( e => e . nodeId === value . after_status_id ) ?. nodeLabel ,
before_owner_id: value . before_owner_id ,
after_owner_id: value . after_owner_id ,
update_time: value . update_time
// Show case record history
$ui . case_history_table . value = array ;