Skip to content

Built-in Functions

Functions to insert, update, and delete records to built-in table in a workflow.

Tips

$fn.createCase

Register a new record in the $case table.

Arguments

NameTypeDescription
paramobjectInput Object
PropertyTypeDescription
databasestringDatabase with built-in tables
status_idstringStatus ID
owner_idstringUser ID of the next person in charge

Return value

TypeDescription
Promise<{case: Case}>Objects with the case property
PropertyTypeDescription
caseCaseCase Object

Tips

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.nextUI('UI02');

$fn.updateCase

Updates the $case table with the target case subject to the case_id according to the argument.

Arguments

NameTypeDescription
paramobjectInput object
PropertyTypeDescription
databasestringDatabase with built-in tables
case_idstringCase ID
status_idstringStatus ID
owner_idstringUser ID of the next person in charge

Return value

TypeDescription
Promise<{case: Case}>Objects with the case property
PropertyTypeDescription
caseCaseCase Object

Tips

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.nextUI('UI02');

$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

NameTypeDescription
paramobjectInput Object
PropertyTypeDescription
databasestringDatabase with built-in tables
case_idstringCase ID

Return value

TypeDescription
Promise<{case: Case}>Objects with the case property
PropertyTypeDescription
caseCaseCase Object

Tips

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.nextUI('UI02');

$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

NameTypeDescription
paramobjectInput Object
PropertyTypeDescription
databasestringDatabase with built-in tables
status_idstringStatus ID
owner_idstringUser ID of the next person in charge

Return value

TypeDescription
Promise<{case: Case}>Objects with the case property
PropertyTypeDescription
caseCaseCase Object

Tips

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.nextUI('UI02');

$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

NameTypeDescription
paramobjectInput Object
PropertyTypeDescription
databasestringDatabase with built-in tables
case_idstringCase ID
status_idstringStatus ID

Return value

TypeDescription
Promise<{case: Case}>Objects with the case property
PropertyTypeDescription
caseCaseCase Object

Tips

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.nextUI('UI02');

$fn.getWorkflowDef

Retrieve workflow definition information defined in the Workflow Editor

Arguments

None

Return value

TypeDescription
array[node]Array with objects for each node
PropertyTypeDescription
nodeNodeNode object
PropertyTypeDescription
nodeIdStringNode ID (start | end | any)
nodeLabelStringNode Label
nodeTypeStringNode type (start | status | end | operation)
statusUiStringStatus UI (none | any)
operationTypeStringOperation Type (none | create | update | remand | reject)
nextOwnerStringNext Owner (none | select_user | current_user)

Sample

/* SQL Function Contents
* ---------------------------------------------------------------------------------
* 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 => {
return {
case_history_id: value.id,
case_id: value.case_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;