Fx.work

Fx.work:和协同工作相关的API

1. createTask 发任务

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. createTaskV2 创建任务v2,返回任务id

Fx.work.createTaskV2(<String title>, <String content>, <DateTime deadLine>, <Boolean multiExecute>, <Map executeUsers>, <Map atUsers>, <List objects>, <List reminds>)

参数说明

参数 类型 说明
title String 任务标题
content String 任务内容
deadLine DateTime 任务完成时间
multiExecute Boolean 是否多人执行
executeUsers Map 执行人
atUsers Map 抄送范围
objects List 关联对象
reminds List 提醒时间 2--事件发生时,3--5分钟前,4--15分钟前,5---30分钟前,6--1小时前,7--2小时前,8--1天前,9--2天前,10-7天前;

返回值类型

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. executeTask 执行任务

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. cancelTask 取消任务

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. createSchedule 创建日程绑定业务对象

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. createSalesRecord 发销售记录

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. addActiveRecord 发活动记录

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)
}

8. feedBatchAddCcEmployeeToFeeds 为一组FeedId增加抄送人

Fx.work.feedBatchAddCcEmployeeToFeeds(<List feedIds>, <Integer ccEmployeeId>)

参数说明

参数 类型 说明
feedIds List 需要更新的feed的id数组
ccEmployeeId Integer 需要增加的人的id

返回值类型

APIResult

返回值说明

Map

Java举例

List feedIds = Lists.newArrayList(100000006,100000004,100000003,100000002);
Integer ccEmployeeId = 1105;
APIResult ret = Fx.work.feedBatchAddCcEmployeeToFeeds(feedIds, ccEmployeeId);
log.info(ret);
if (ret.isError()) {
  log.info(ret.message());
} else{
  log.info(ret.getData());
}

Groovy举例

List feedIds = [100000006,100000004,100000003,100000002]
Integer ccEmployeeId = 1105
def(Boolean error, Map data, String errorMessage) = Fx.work.feedBatchAddCcEmployeeToFeeds(feedIds, ccEmployeeId)
log.info(ret)
if (error) {
  log.info(errorMessage)
} else{
  log.info(data)
}

9. followUpSearchResourceListByUUID 查询跟进动态里的FeedId

Fx.work.followUpSearchResourceListByUUID(<String objectApiName>, <String objectId>, <Long fromFeedId>, <Integer limit>)

参数说明

参数 类型 说明
objectApiName String 对象apiname
objectId String 对象id
fromFeedId Long feed翻页的id,取上一页最小的feedid,可以为null
limit Integer 每页的数量,最大200,可以为null

返回值类型

APIResult

返回值说明

Map

Java举例

String objectApiName = "AccountObj";
String objectId = "631859a4cd0f460001e69bf2";
Long fromFeedId = 100000006;
Integer limit = 2;
APIResult ret = Fx.work.followUpSearchResourceListByUUID(objectApiName, objectId, fromFeedId, limit);
log.info(ret);
if (ret.isError()) {
  log.info(ret.message());
} else{
  log.info(ret.getData());
}

Groovy举例

String objectApiName = "AccountObj"
String objectId = "631859a4cd0f460001e69bf2"
Long fromFeedId = 100000006
Integer limit = 2
def(Boolean error, Map data, String errorMessage) = Fx.work.followUpSearchResourceListByUUID(objectApiName, objectId, fromFeedId, limit)
log.info(ret)
if (error) {
  log.info(errorMessage)
} else{
  log.info(data)
}

参考类 com.fxiaoke.functions.enums.RemindTime

2024-05-16
4 4