BPM实例ID
添加文件信息的记录,需要符合attachfile表的字段要求
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res = instClient.addAttachments("002N000000VwBrSDISbQ", [
{
"name": "aaa",
"fileName": "a/b/c",
"category": "xxx",
"url": "xxx.com/xxx/xxx",
"taskID": "xxx",
},
{
"name": "bbb",
"fileName": "a/b/c/d",
"category": "yyy",
"url": "yyy.com/yyy/yyy",
"taskID": "yyy",
}
])
console.log(res)
添加成功的文件附件信息的记录id列表
撤销BPM流程实例
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.cancel("002N000000VwBrSDISbQ", "my reason")
BPM实例运行状态信息
删除BPM实例以及相关资源
BPM实例ID,若ID不存在会报错
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.delete("bpInstanceId")
为运行BPM实例删除文件附件
BPM实例ID
需要删除的文件附件记录id列表
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.deleteAttachments("002N000000VwBrSDISbQ", ["10gh000000VwbArnQ75E"])
获取可跳转的元素列表。
BPM实例ID
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let recs = instClient.getJumpableElements("002N000000VwBrSDISbQ")
console.log(recs)
目前仅支持以下节点的跳转:
确定流程实例的方法主要通过任务的 parentId 确定。对于会签来说,需要获取个人任务的父任务(会签任务)的 parentId 才能确定。
可跳转的元素列表
{
"task1": true,
"task2": true
}
获取BPM实例相关的变量值
import * as bp from 'bp'
let instClient=bp.newInstanceClient()
let vars = instClient.getVars("002N000000VwBrSDISbQ", ["foo", "bar"])
console.log(vars)
查询出的变量值
关闭当前任务并跳转到指定名称的任务。
BPM实例ID
用户任务的名称
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.jumpToElement("002N000000VwBrSDISbQ", "task1")
getJumpableElements 获取可跳转节点列表
查询具体BPM实例状态信息
BPM实例ID
Optional
options: OptionItem可选参数,可部分留空或全部留空
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res = instClient.query("002N000000VwBrSDISbQ", {
fields: ["name", "bpStatus", "createdDate", "owner"],
})
console.log(res)
BPM实例状态信息
查询激活状态的bpm实例(激活状态是指以下几种状态"New"、"Waiting for user interaction"、"Waiting for page event"、"Paused"、"Dispatched")
Optional
queryCondition: QueryCondition查询条件,可部分留空或全部留空
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let recs = instClient.queryActiveList({
owner: "10gd000000KMFW1lhYZ6",
options: {
fields: ["name", "bpStatus", "createdDate", "owner"],
}
})
console.log(recs)
查询出BPM实例的记录
查询BPM运行实例的文件附件记录
BPM实例ID
Optional
options: OptionItem可选参数,可部分留空或全部留空
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let recs = instClient.queryAttachments("002N000000VwBrSDISbQ", {
fields: ["taskID", "name", "fileName", "url"],
limit: 5,
})
console.log(recs)
多条关于指定BPM实例的文件附件信息
按自定condition和option来查询BPM实例
Optional
condition: "bp".ConditionOption指定的查询条件,若不指定具体condition或option留空即可
import * as bp from 'bp'
import * as db from 'db'
let instClient = bp.newInstanceClient()
let res = instClient.queryByCondition({
condition: {
conjunction: db.Conjunction.AND,
conditions: [
{
field: "createdDate",
operator: db.Operator.gt,
value: "2019-08-01 00:00:00"
}
]
},
options: {
fields: ["name", "state", "version", "bpStatus", "createdDate"],
orderby: [
{
field: "name",
order: db.Order.desc
}
],
}
})
console.log(res)
查询出BPM实例的记录
查询BPM实例相关的评论
BPM实例ID
Optional
options: OptionItem可选参数,可部分留空或全部留空
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.queryComments("bpInstanceId")
BPM实例的评论记录
查询BPM实例的历史记录
BPM实例ID
Optional
category: string可选参数,指定查询历史的category,可以留空或置为undefined
Optional
options: OptionItem可选参数,可部分留空或全部留空
Optional
sources: string[]可选参数,历史记录的产生来源,用来根据数据来源筛选查询的历史记录。 Process: BPM流程实例上报的历史日志 UserTask: 用户任务图元上报的历史日志 CallActivity: 调用其他BPM流程图元上报的历史日志 Wait: 事件等待图元上报的历史日志 Task: 代办任务实例上报的历史日志
Optional
kinds: string[]流程、任务状态。用于BPM历史记录查询接口,用来根据状态筛选历史日志。 created: 流程、图元或者任务创建/启动 completed: 流程、图元或者任务正常完成 suspended: 流程或者任务被挂起 resumed: 流程或者任务被恢复 terminated: 流程或者任务被终止 canceled: 流程或者任务被取消/撤回 delegated: 任务被委托 claimed: 任务(分配群组的)被认领 transferred: 任务被转移
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res = instClient.queryHistory("002N000000VwBrSDISbQ", undefined, {
fields: ["name", "bpStatus", "category", "owner"],
}, ["Process","UserTask"], ["created", "completed"])
console.log(res)
多条关于指定BPM实例的历史记录
按指定条件查询BPM实例
Optional
stateCondition: StateCondition查询条件,可部分留空或全部留空,其中states参数可使用预定义枚举值
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let recs = instClient.queryList({
creator: "10gd000000KMFW1lhYZ6",
states: [
bp.State.New,
bp.State.Suspended,
bp.State.Dispatched,
]
})
console.log(recs)
返回BPM实例记录
查询属主是调用者本人的bpm实例
Optional
options: OptionItem查询设置,可为空
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let recs = instClient.queryMyList({
fields: ["name", "bpStatus", "createdDate", "owner"],
})
console.log(recs)
查询出BPM实例的记录
查询BPM实例任务流程列表
BPM实例ID
Optional
options: DisplayOption可选参数,设置返回结构,默认为tree树形结构
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res = instClient.queryProcessTasks("002N000000VwBrSDISbQ", {"mode": "tree", "type": "all"})
console.log(res)
多条关于指定BPM实例的任务执行流程
查询suspended状态的bpm实例, 示例与queryActiveList类似
Optional
queryCondition: QueryCondition查询条件,可部分留空或全部留空
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res=instClient.querySuspendList({
owner: "10gd000000KMFW1lhYZ6",
options: {
fields: ["name", "bpStatus", "createdDate", "owner"],
}
})
查询出BPM实例的记录
查询一个BPM实例所对应的任务列表
BPM实例ID
Optional
states: string[]指定要查询任务的状态,可使用枚举值,如不指定具体内容可留空或写为undefined
Optional
options: OptionItem可选参数,可部分留空或全部留空
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res = instClient.queryTasks("002N000000VwBrSDISbQ", [bp.State.Terminated, "Closed"], {
fields: ["name", "owner", "state"]
})
console.log(res)
重置BPM流程实例。即撤销正在执行的流程实例并重新启动
BPM实例ID,若ID不存在会报错
Optional
reason: string撤销原因,可选
Optional
inputs: Dict需要修改的流程变量值,可选
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.restart("002N000000VwBrSDISbQ", "my reason", {
"foo": 1,
"bar": 3
})
BPM实例运行状态信息
恢复一个suspended状态的BPM实例
BPM实例ID,若ID不存在会报错,若该实例非suspended状态,则无返回
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res = instClient.resume("002N000000VwBrSDISbQ")
console.log(res)
BPM实例运行状态信息
撤回用户任务
BPM实例ID,若ID不存在会报错
Optional
taskID: stringtask实例ID,若task已完成,则可以不填写
Optional
allowClose: boolean是允许撤回已完成task
Optional
create: boolean是否重新创建撤回节点的上一个节点
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.revokePreTask("002N000000VwBrSDISbQ", "002Q000000VwBrSDISbQ",true,true)
BPM实例运行状态信息
打回用户任务
BPM实例ID,若ID不存在会报错
Optional
taskID: stringtask实例ID,若task已完成,则可以不填写
Optional
allowClose: boolean是允许打回已完成task
Optional
create: boolean是否重新创建打回节点的上一个节点
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.rollBackPreTask("002N000000VwBrSDISbQ", "002Q000000VwBrSDISbQ",true,true)
BPM实例运行状态信息
设置BPM实例相关的变量值
BPM实例ID
参数key-value键值对,注意设置的变量名是BPM定义过的变量
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.setVars("002N000000VwBrSDISbQ", {
"foo": "aaa",
"bar": "bbb"
})
启动一个BPM实例
BPM名
版本号,如"1.0.1"
入参,如无入参,可放置空Map{}
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res = instClient.start("test", "1.0.1", {
"foo": 1,
"bar": 3
})
console.log(res)
BPM实例运行状态信息
{
"name": "test",
"version": "1.0.1",
"id": "002N000000VwAuoT0WjA",
"processDefID": "001L000000VBjcAIJjGa",
"interviewLabel": "test",
"nextElem": "userTask",
"isTest": true,
"state": "Dispatched",
"bpStatus": "新建",
...
...
}
暂停一个运行的BPM实例
BPM实例ID,若ID不存在会报错
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
let res = instClient.suspend("002N000000VwBrSDISbQ")
console.log(res)
BPM实例运行状态信息
终结一个BPM实例以及相关资源
BPM实例ID,若ID不存在会报错
Optional
reason: string可选参数,终结实例原因,不写可留空或写undefined
import * as bp from 'bp'
let instClient = bp.newInstanceClient()
instClient.terminate("bpId","bp is end")
为运行BPM实例添加文件附件