Fx.work
Fx.work:和协同工作相关的API
1. 发任务
Fx.work.createTask(<String title>, <String content>, <DateTime deadLine>, <Map executeUsers>, <Map atUsers>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
title | String | 任务标题 |
content | String | 任务内容 |
deadLine | DateTime | 任务完成时间 |
executeUsers | Map | 执行人 |
atUsers | Map | 抄送范围 |
返回值类型
APIResult
返回值说明
Java举例
DateTimeDuration day = DateTimeDuration.Days(1);
DateTime deadLine = DateTime.now().plus(day);
Map<String, List<String>>executeUsers = Maps.newHashMap();
executeUsers.put("users", Lists.newArrayList("1059"));
Map<String, List<String>>atUsers = Maps.newHashMap();
atUsers.put("users", Lists.newArrayList("1059","1025"));
atUsers.put("departments", Lists.newArrayList("253937"));
APIResult ret = Fx.work.createTask("hello", "world", deadLine, executeUsers, atUsers);
if (ret.isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy举例
DateTime deadLine = DateTime.now + 1.days
Fx.work.createTask("hello", "world", deadLine, [users: ["1059"]], [users: ["1059","1025"],departments:["253937"]])
注意事项
- executeUsers map keys : "users" 用户 ,"departments" 部门 atUsers map keys : "users" 用户 ,"departments" 部门
2. 创建任务v2,返回任务id
Fx.work.createTaskV2(<String title>, <String content>, <DateTime deadLine>, <boolean multiExecute>, <Map executeUsers>, <Map atUsers>, <List objects>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
title | String | 任务标题 |
content | String | 任务内容 |
deadLine | DateTime | 任务完成时间 |
multiExecute | boolean | 是否多人执行 |
executeUsers | Map | 执行人 |
atUsers | Map | 抄送范围 |
objects | List | 关联对象 |
返回值类型
APIResult
返回值说明
String
Java举例
DateTimeDuration day = DateTimeDuration.Days(1);
DateTime deadLine = DateTime.now().plus(day);
Map<String, List<String>>executeUsers = Maps.newHashMap();
executeUsers.put("users", Lists.newArrayList("1059"));
Map<String, List<String>>atUsers = Maps.newHashMap();
atUsers.put("users", Lists.newArrayList("1059","1025"));
atUsers.put("departments", Lists.newArrayList("253937"));
List<Map<String, String>>objects = Lists.newLinkedList();
objects.add(Maps.of("object_api_name", "object_l9348__c", "id", "60d53e038bc25c00016c75f6"));
objects.add(Maps.of("object_api_name", "ContractObj", "id", "60f54c9c4fc0fa000107c1f7"));
objects.add(Maps.of("object_api_name", "ContractObj", "id", "8e82821584474cb79ae693c267cc7395"));
APIResult ret = Fx.work.createTaskV2("hello", "world", deadLine, false, executeUsers, atUsers, objects);
if (ret.isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy举例
DateTime deadLine = DateTime.now + 1.days
List objects = [
[object_api_name: "object_l9348__c", id: "60d53e038bc25c00016c75f6"],
[object_api_name: "ContractObj", id: "60f54c9c4fc0fa000107c1f7"],
[object_api_name: "ContractObj", id: "8e82821584474cb79ae693c267cc7395"]
]
def (Boolean error, String taskId, String errorMessage) = Fx.work.createTaskV2("hello", "world", deadLine, false, [users: ["1000"]], [users: ["1000"]], objects)
if (error) {
log.info(errorMessage)
} else {
log.info(taskId)
}
3. 执行任务
Fx.work.executeTask(<String taskId>, <String executor>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
taskId | String | 任务id |
executor | String | 任务执行人 |
返回值类型
APIResult
返回值说明
Java举例
APIResult ret = Fx.work.executeTask("3b4d8c49b207417f99941688c8ee719f", "1017");
if (ret.isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy举例
Fx.work.executeTask("3b4d8c49b207417f99941688c8ee719f", "1017")
4. 取消任务
Fx.work.cancelTask(<String taskId>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
taskId | String | 任务id |
返回值类型
APIResult
返回值说明
Java举例
APIResult ret = Fx.work.cancelTask("3b4d8c49b207417f99941688c8ee719f");
if (ret.isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy举例
Fx.work.cancelTask("3b4d8c49b207417f99941688c8ee719f")
5. 创建日程绑定业务对象
Fx.work.createSchedule(<String content>, <DateTime beginTime>, <DateTime endTime>, <boolean isFullDate>, <boolean needReceipt>, <List remindTimes>, <Map attenders>, <List objects>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
content | String | 日程内容 |
beginTime | DateTime | 日程开始时间 |
endTime | DateTime | 日程结束时间 |
isFullDate | boolean | 是否全天日程 |
needReceipt | boolean | 是否需要回执 |
remindTimes | List | 提醒时间 |
attenders | Map | 抄送范围/参与人 |
objects | List | 绑定的对象数据 |
返回值类型
APIResult
返回值说明
Java举例
DateTimeDuration day = DateTimeDuration.Days(1);
DateTime endTime = DateTime.now().plus(day);
Map<String, List<String>>attenders = Maps.newHashMap();
attenders.put("users", Lists.newArrayList("1001","1017","1018"));
List<Map<String, String>>objects = Lists.newLinkedList();
objects.add(Maps.of("apiName", "LeadsObj", "dataId", "5dc276e1a25b1800018dafe9"));
objects.add(Maps.of("apiName", "AccountObj", "dataId", "5f3f86136ede600001da386e"));
APIResult ret = Fx.work.createSchedule("hello", DateTime.now(), endTime , false, false, Lists.newArrayList(RemindTime.BEGIN()), attenders, objects);
if (ret.isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy举例
DateTime endTime = DateTime.now + 1.hours;
def ret = Fx.work.createSchedule("hello", DateTime.now(), endTime , false, false, [RemindTime.BEGIN()], [users: ["1001","1017","1018"]], [[apiName:"LeadsObj", dataId:"5dc276e1a25b1800018dafe9"],[apiName:"AccountObj", dataId:"5f3f86136ede600001da386e"]]);
(1).参考RemindTime
注意事项
- atUsers map keys : "users" 用户 ,"departments" 部门 object keys : "apiName" 对象API名称 ,"dataId" 业务数据Id
6. 发销售记录
Fx.work.createSalesRecord(<String content>, <List objects>, <Map atUsers>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
content | String | 销售记录内容 |
objects | List | 关联对象 |
atUsers | Map | 抄送范围 |
返回值类型
APIResult
返回值说明
Java举例
Map<String, List<String>>attenders = Maps.newHashMap();
attenders.put("users", Lists.newArrayList("1001","1017","1018"));
List<Map<String, String>>objects = Lists.newLinkedList();
objects.add(Maps.of("object_api_name", "object_l9348__c", "id", "60d53e038bc25c00016c75f6"));
APIResult ret = Fx.work.createSalesRecord("hello", objects, attenders);
if (ret.isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy举例
Fx.work.createSalesRecord("hello", [[object_api_name : "AccountObj", id : "4d79c3068aca42b28aebbc98223e8bed"]], [users : [ "1025"]])
7. 发活动记录
Fx.work.addActiveRecord(<ActiveRecord activeRecord>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
activeRecord | ActiveRecord | 活动记录 |
返回值类型
APIResult
返回值说明
Groovy举例
ActiveRecord activeRecord = ActiveRecord.build {
//销售记录内容
text = "hello"
//活动记录字段字段,和其他数据 Map
recordData = [active_record_type: "0"]
//关联的对象List<Map>refObjects = [[apiName: "AccountObj", objectId: "5e4df95ccccd3a0001ebeac6"]]
range {
departments = []
users = []
}
images = [Image.of(name: "name", nPath: "path", size: 0, ext: ".doc")]
attachments = [Attachment.of(name: "name", nPath: "path", size: 0)]
}
def (boolean error, Object data, String msg) = Fx.work.addActiveRecord(activeRecord)
if (error) {
log.info(data)
} else {
log.info(msg)
}