Interface BPMTaskClient

interface BPMTaskClient {
    addAttachments: ((taskInsId, recs) => string[]);
    addComment: ((taskInsId, comment) => Dict);
    cancel: ((taskInsId, reason?) => Dict);
    claim: ((taskInsId) => Dict);
    complete: ((taskInsId, outcome, inputs) => Dict);
    completeWithAssignee: ((taskInsId, assignee, outcome, inputs) => Dict);
    createSubTask: ((procInsId, parentId, assignee) => Dict);
    delegate: ((taskInsId, assignee, reason?) => Dict);
    delete: ((taskInsId) => void);
    deleteAttachments: ((taskInsId, idList) => void);
    deleteComment: ((taskInsId, commentId) => void);
    getComment: ((taskInsId, commentId, options?) => Dict);
    getComments: ((taskInsId, options?) => Dict[]);
    getVars: ((taskInsId, names) => Dict);
    query: ((taskInsId, options?) => Dict);
    queryActiveList: ((activeTaskCondition?) => Dict[]);
    queryAttachments: ((taskInsId, options?) => Dict[]);
    queryByCondition: ((condition?) => Dict[]);
    queryClosedList: ((queryCondition?) => Dict[]);
    queryCompletedList: ((queryCondition?) => Dict[]);
    queryList: ((queryTaskListCondition?) => Dict[]);
    queryMyList: ((myTaskCondition?) => Dict[]);
    querySuspendList: ((queryCondition?) => Dict[]);
    rollbackSpecifiedTask: ((taskInsId, outcome, inputs) => FlowInstance);
    setVars: ((taskInsId, inputs) => void);
    terminate: ((taskInsId, reason?) => Dict);
    transfer: ((taskInsId, assignee, reason?) => Dict);
    updateComment: ((taskInsId, commentId, comment) => void);
}

Properties

addAttachments: ((taskInsId, recs) => string[])

为BPM任务添加文件附件信息

Type declaration

    • (taskInsId, recs): string[]
    • Parameters

      • taskInsId: string

        任务实例ID

      • recs: Dict[]

        文件附件信息记录

      Returns string[]

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.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)

Returns

返回新增文件附件信息记录的id列表

addComment: ((taskInsId, comment) => Dict)

为BPM任务添加评论

Type declaration

    • (taskInsId, comment): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • comment: string

        评论信息

      Returns Dict

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.addComment("comments")

Returns

返回添加的评论相关记录

cancel: ((taskInsId, reason?) => Dict)

取消并行任务

Type declaration

    • (taskInsId, reason?): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • Optional reason: string

        可以置空

      Returns Dict

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let tasks = taskClient.cancel(
"002N000000VBk5qqWi1I",
"task is end"
)
console.log(tasks)

Returns

任务状态信息

claim: ((taskInsId) => Dict)

申请处理指定的任务

Type declaration

    • (taskInsId): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      Returns Dict

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.claim(
"002N000000VBk5qqWi1I"
)

Returns

任务状态信息

complete: ((taskInsId, outcome, inputs) => Dict)

结束任务

Type declaration

    • (taskInsId, outcome, inputs): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • outcome: string

        可以指定任务结果状态,如果为空字符串,任务状态将默认置为"complete"

      • inputs: Dict

        可以设置BPM任务的变量,如果为空Map{}则不修改变量值

      Returns Dict

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.complete(
"002N000000VBk5qqWi1I",
"",
{}
)
console.log(res)

Returns

任务状态信息

completeWithAssignee: ((taskInsId, assignee, outcome, inputs) => Dict)

结束任务,并指定下一个任务的参与者(必须在下一个任务的参与者列表中,或具有管理权限)。

Type declaration

    • (taskInsId, assignee, outcome, inputs): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • assignee: string
      • outcome: string

        可以指定任务结果状态,如果为空字符串,任务状态将默认置为"complete"

      • inputs: Dict

        可以设置BPM任务的变量,如果为空Map{}则不修改变量值

      Returns Dict

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.completeWithAssignee(
"002N000000VBk5qqWi1I",
"user",
"",
{}
)
console.log(res)

Returns

任务状态信息

createSubTask: ((procInsId, parentId, assignee) => Dict)

创建一个BPM子任务实例,注意parentId对应任务不能是用户任务

Type declaration

    • (procInsId, parentId, assignee): Dict
    • Parameters

      • procInsId: string

        bp实例的ID

      • parentId: string

        父任务的ID

      • assignee: string

        用户标识,可以是用户的登录账号,也可以是用户的ID

      Returns Dict

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.createSubTask(
"002N000000VBk5qqWi1I",
"002N000000VBk5qqWaSd",
"user",
)
console.log(res)

Returns

任务状态信息

delegate: ((taskInsId, assignee, reason?) => Dict)

将任务进行委托

Type declaration

    • (taskInsId, assignee, reason?): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • assignee: string

        被委托的用户标识,可以是用户的登录账号,也可以是用户的ID

      • Optional reason: string

        可以置空

      Returns Dict

Example

import {delegate}from 'bp'
delegate("002N000000VwBrSDISbQ","user","resons")

Returns

任务状态信息

delete: ((taskInsId) => void)

删除任务

Type declaration

    • (taskInsId): void
    • Parameters

      • taskInsId: string

        任务实例ID

      Returns void

Example

import * as bp from 'bp'
let task = bp.newTaskClient()
task.delete("taskInsId")
deleteAttachments: ((taskInsId, idList) => void)

删除BPM任务的文件附件信息

Type declaration

    • (taskInsId, idList): void
    • Parameters

      • taskInsId: string

        任务实例ID

      • idList: string[]

        要删除的附件信息记录id列表

      Returns void

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
taskClient.deleteAttachments("002N000000VwBrSDISbQ",["id1","id2"])
deleteComment: ((taskInsId, commentId) => void)

删除BPM任务的评论

Type declaration

    • (taskInsId, commentId): void
    • Parameters

      • taskInsId: string

        任务实例ID

      • commentId: string

        评论实例ID

      Returns void

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.deleteComment("taskInsId","commentId")
getComment: ((taskInsId, commentId, options?) => Dict)

获取某个具体的BPM任务评论

Type declaration

    • (taskInsId, commentId, options?): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • commentId: string

        评论实例ID

      • Optional options: OptionItem

        可选参数,可部分置空或全部置空

      Returns Dict

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.getComment("taskInsId","commentId")

Returns

返回某个具体的评论记录

getComments: ((taskInsId, options?) => Dict[])

获取BPM任务的评论

Type declaration

    • (taskInsId, options?): Dict[]
    • Parameters

      • taskInsId: string
      • Optional options: OptionItem

        可选,可部分置空或全部置空

      Returns Dict[]

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.getComments("taskInsId")

Returns

返回相关的评论记录

getVars: ((taskInsId, names) => Dict)

获取BPM任务的变量值

Type declaration

    • (taskInsId, names): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • names: string[]

        要查询的变量值列表,如果填入空数组,则查询所有变量

      Returns Dict

Example


import * as bp from 'bp'
let taskClient=bp.newTaskClient()
let vars = taskClient.getVars("002N000000VwBrSDISbQ", ["foo", "bar"])
console.log(vars)

Returns

变量Key-Value键值对

query: ((taskInsId, options?) => Dict)

指定具体BPM任务ID,查任务信息

Type declaration

    • (taskInsId, options?): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • Optional options: OptionItem

        可选,可部分置空或全部置空

      Returns Dict

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.query("002N000000VwBrSDISbQ", {
fields: ["name", "bpStatus", "createdDate", "owner"],
})
console.log(res)

Returns

任务信息

queryActiveList: ((activeTaskCondition?) => Dict[])

查询活跃状态的BPM任务列表,这里激活状态包括New/Dispatched/InProcess这三种任务状态

Type declaration

    • (activeTaskCondition?): Dict[]
    • Parameters

      • Optional activeTaskCondition: ActiveTaskCondition

        查询活跃状态任务的条件,可部分留空或全部留空

      Returns Dict[]

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let tasks = taskClient.queryActiveList({
owner: "002I000000VBjYt2OCYK",
rootID: "002N000000VBjj8I66gC",
options: {
fields: ["assignee", "assigneeID", "assigneeType", "assigneeName", "name", "state", "rootID", "owner"],
}
})
console.log(tasks)

Returns

返回匹配的任务列表

queryAttachments: ((taskInsId, options?) => Dict[])

查询BPM任务的文件附件信息记录

Type declaration

    • (taskInsId, options?): Dict[]
    • Parameters

      • taskInsId: string

        任务实例ID

      • Optional options: OptionItem

        可选,可部分置空或全部置空

      Returns Dict[]

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let recs = taskClient.queryAttachments("002N000000VwBrSDISbQ", {
fields: ["taskID", "name", "fileName", "url"],
limit: 5,
})
console.log(recs)

Returns

查询到的文件附件信息记录

queryByCondition: ((condition?) => Dict[])

按照指定条件查BPM任务

Type declaration

    • (condition?): Dict[]
    • Parameters

      • Optional condition: "bp".ConditionOption

        指定的查询条件,若不指定具体condition或option留空即可

      Returns Dict[]

Example


import * as bp from 'bp'
import * as db from 'db'
let taskClient = bp.newTaskClient()
let res = taskClient.queryByCondition({
condition: {
conjunction: db.Conjunction.AND,
conditions: [
{
field: "createdDate",
operator: db.Operator.gt,
value: "2019-08-01 00:00:00"
}
]
},
options: {
fields: ["assignee", "assigneeID", "assigneeType", "assigneeName", "name"],
orderby: [
{
field: "assignee",
order: db.Order.desc
}
],
}
})
console.log(res)

Returns

返回查询出的BPM任务的记录

queryClosedList: ((queryCondition?) => Dict[])

查询closed状态的bpm任务,示例与querySuspendList类似

Type declaration

    • (queryCondition?): Dict[]
    • Parameters

      • Optional queryCondition: QueryCondition

        查询条件,可以全部为空或部分为空

      Returns Dict[]

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.queryClosedList({
creator: "002I000000VBjYt2OCYK",
owner: "002I000000VBjYt2OCYK"
})
console.log(res)

Returns

查询返回的任务列表

queryCompletedList: ((queryCondition?) => Dict[])

查询completed状态的bpm任务,示例与querySuspendList类似

Type declaration

    • (queryCondition?): Dict[]
    • Parameters

      • Optional queryCondition: QueryCondition

        查询条件,可以全部为空或部分为空

      Returns Dict[]

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.queryCompletedList({
creator: "002I000000VBjYt2OCYK",
owner: "002I000000VBjYt2OCYK"
})
console.log(res)

Returns

查询返回的任务列表

queryList: ((queryTaskListCondition?) => Dict[])

按照指定条件查询BPM任务列表

Type declaration

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.queryList({
rootID: "002N000000VBk5qqWi1I",
states: [bp.State.Terminated, bp.State.New],
procInsID: "xxxxxxxxxxxxxxxxxx",
})
console.log(res)

Returns

查询返回的任务列表

queryMyList: ((myTaskCondition?) => Dict[])

查询属主是调用者本人的BPM任务列表

Type declaration

    • (myTaskCondition?): Dict[]
    • Parameters

      • Optional myTaskCondition: MyTaskCondition

        查询自己BPM任务的条件,可部分留空或全部留空

      Returns Dict[]

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let tasks = taskClient.queryMyList({
instID: "002N000000VwBrSDISbQ",
rootID: "002N000000VBjj8I66gC",
options: {
fields: ["assignee", "assigneeID", "assigneeType", "assigneeName", "name", "state", "rootID", "owner"],
}
})
console.log(tasks)

Returns

返回匹配的任务列表

querySuspendList: ((queryCondition?) => Dict[])

查询suspended状态的bpm任务

Type declaration

    • (queryCondition?): Dict[]
    • Parameters

      • Optional queryCondition: QueryCondition

        查询条件,可以全部为空或部分为空

      Returns Dict[]

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.querySuspendList({
creator: "002I000000VBjYt2OCYK",
owner: "002I000000VBjYt2OCYK"
})
console.log(res)

Returns

查询返回的任务列表

rollbackSpecifiedTask: ((taskInsId, outcome, inputs) => FlowInstance)

结束任务

Type declaration

    • (taskInsId, outcome, inputs): FlowInstance
    • Parameters

      • taskInsId: string

        任务实例ID

      • outcome: string

        可以指定任务结果状态,如果为空字符串,任务状态将默认置为"complete"

      • inputs: Dict

        可以设置BPM任务的变量,如果为空Map{}则不修改变量值

      Returns FlowInstance

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.rollbackSpecifiedTask(
"002N000000VBk5qqWi1I",
"",
{}
)
console.log(res)

Returns

任务状态信息

setVars: ((taskInsId, inputs) => void)

设置BPM任务中定义变量的值

Type declaration

    • (taskInsId, inputs): void
    • Parameters

      • taskInsId: string

        任务实例ID

      • inputs: Dict

        参数key-value键值对,注意设置的变量名是BPM定义过的变量

      Returns void

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
taskClient.setVars("002N000000VwBrSDISbQ", {
"foo": "aaa",
"bar": "bbb"
})
terminate: ((taskInsId, reason?) => Dict)

终止任务

Type declaration

    • (taskInsId, reason?): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • Optional reason: string

        可以置空

      Returns Dict

Example

import * as bp from 'bp'
let taskClient = bp.newTaskClient()
taskClient.terminate("bpId","bp is end")

Returns

任务状态信息

transfer: ((taskInsId, assignee, reason?) => Dict)

让系统将任务转移给他人

Type declaration

    • (taskInsId, assignee, reason?): Dict
    • Parameters

      • taskInsId: string

        任务实例ID

      • assignee: string

        被委托的用户标识

      • Optional reason: string

        可以置空

      Returns Dict

Example

import * as bp from 'bp'
let taskClient = bp.newTaskClient()
taskClient.transfer("bpId","userId","")

Returns

任务状态信息

updateComment: ((taskInsId, commentId, comment) => void)

更新BPM任务的评论

Type declaration

    • (taskInsId, commentId, comment): void
    • Parameters

      • taskInsId: string

        任务实例ID

      • commentId: string

        评论实例ID

      • comment: string

        评论信息

      Returns void

Example


import * as bp from 'bp'
let taskClient = bp.newTaskClient()
let res = taskClient.updateComment("taskInsId","commentId","comment")