Fx.object:和对象操作有关的API 和对象操作有关的API
1. create 主从对象同时入库
Fx.object.create(<String apiName>, <Map objectData>, <Map details>, <CreateAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectData | Map | 主对象数据即字段值 |
details | Map | 从对象数据 |
attribute | CreateAttribute | 创建属性设置 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
Map result = Fx.object.create(
"object_master__c", // apiName
Maps.of("name", "主从同时新建"), //主对象
Maps.of(
"object_detail1__c",Lists.newArrayList( // 从对象
Maps.of("name", "张三1", "customFiled__c", "test1"),
Maps.of("name", "李四1", "customField__c", "test2")),
"object_detail2__c", Lists.newArrayList(
Maps.of("name", "张三2", "customFiled__c", "test1"),
Maps.of("name", "李四2", "customField__c", "test2"))
), CreateAttribute.builder().triggerWorkflow(true).build()).result();
log.info(result)
Groovy举例
Map masterData = [
"name": "主从同时新建1", //主属性是String类型
"owner" : ['1000'], //人员字段是List类型
"field_4zWog__c": [ //附件,人员字段是List<Map>,有filename,path,size,ext四个字段
[
"filename":"新建选择业务类型.png",
"path":"N_202302_16_4acf04c3eb5046c08316e6e5da78ddfa",
"size":80848,
"ext":"png"
]
],
"field_p1M7F__c": Date.now().toTimestamp(), //日期,时间和日期时间字段都是时间戳Long
"field_6Lol2__c": Time.now().toTimestamp(),
]
Map detailData = [
"object_detail1__c":[["name":"张三1","customFiled__c":"test1"],["name":"李四1","customField__c":"test2"]],
"object_detail2__c":[["name":"张三2","customFiled__c":"test1"],["name":"李四2","customField__c":"test2"]]
]
def ret = Fx.object.create("object_1yO4J__c", masterData, detailData, CreateAttribute.builder().build()).result() as Map
log.info(ret)
(1).参考CreateAttribute
注意事项
- 参数 Details 为空时,表示不创建从对象
2. batchCreate 最多支持500行一批的批量创建数据
Fx.object.batchCreate(<String apiName>, <List objects>, <CreateAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objects | List | 对象数据即字段值 |
attribute | CreateAttribute | 创建属性设置 |
返回值类型
APIResult
返回值说明
返回的数据类型: List <Map>
Java举例
List ret = Fx.object.batchCreate(
"AccountObj",
Lists.newArrayList(Maps.of("name", "客户1"), Maps.of("name", "客户2")),
CreateAttribute.builder().build()).result() as List;
log.info(ret);
Groovy举例
List dataList = [
[
"name": "主属性",
"owner" : ['1000'],
"field_p1M7F__c": Date.now().toTimestamp(),
"field_6Lol2__c": Time.now().toTimestamp(),
]
]
def ret = Fx.object.batchCreate("AccountObj", dataList, CreateAttribute.builder().build()).result() as List
log.info(ret)
(1).参考CreateAttribute
3. update IncrementUpdate更新数据对象
Fx.object.update(<String apiName>, <String objectId>, <Map updateFields>, <UpdateAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectId | String | 数据ID |
updateFields | Map | 对象数据即字段值 |
attribute | UpdateAttribute | 可选参数 |
返回值类型
APIResult
返回值说明
data数据类型 Map
Groovy举例
String objectAPIName = 'object_s82CA__c'
String dataId = '64b1113e87ec1c0001bfc102'
Map updateData = [
"name":"sss"
]
def (Boolean error, Map data, String errorMessage) = Fx.object.update(objectAPIName, dataId, updateData, UpdateAttribute.builder().triggerWorkflow(true).build())
if (error) {
log.info("error:" + errorMessage )
}
log.info(data)
(1).参考UpdateAttribute
注意事项
- 该更新不会触发编辑按钮的前验证后动作
不支持更新的字段
owner 负责人
mc_currency 不能将币种、汇率更新为空
mc_exchange_rate 不能将币种、汇率更新为空
mc_exchange_rate_version 不能将币种、汇率更新为空
mc_functional_currency 不能将币种、汇率更新为空
formula计算字段
count统计字段
4. update Edit主从《覆盖》更新,如果从对象给空则会清空从对象。
Fx.object.update(<String apiName>, <String objectId>, <Map updateFields>, <Map detailData>, <ActionAttribute actionAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectId | String | 对象数据即字段值 |
updateFields | Map | 对象数据即字段值 |
detailData | Map | 从对象数据 |
actionAttribute | ActionAttribute | 可选参数 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
String objectApiName = "object_qs2nb__c";
String objectId = "607d5e3dd02b9f00016507d8";
Map objectMap = Maps.of("name", "校验");
Map detailMap = Maps.of("object_cDxt8__c", Maps.of("name", "我是从对象,我被函数更改了"));
Map result = Fx.object.update(objectApiName, objectId, objectMap, detailMap, ActionAttribute.create()).result();
log.info(result);
Groovy举例
String objectApiName = "object_qs2nb__c"
String objectId = "607d5e3dd02b9f00016507d8"
def objectMap = ["name":"校验"]
def detailMap = [
"object1":[["name": "我是从对象1,我被函数更改了"]],
"object2":[["name": "我是从对象2,我被函数更改了"]]
]
def result = Fx.object.update(objectApiName, objectId, objectMap, detailMap, ActionAttribute.create()).result() as Map
log.info(result)
(1).参考ActionAttribute
注意事项
- 如不想更新从对象,则detailData参数给null,如果传空数组,则会清空从对象
- 该全量更新接口无法更新锁定的数据,如需更新,可以使用增量更新接口
5. update 按照查询条件批量更新数据,该功能灰度中,请申请灰度后使用
Fx.object.update(<String apiName>, <QueryTemplate template>, <Map updateFields>, <UpdateAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
template | QueryTemplate | 查询条件,详见QueryTemplate说明 |
updateFields | Map | 需要更新的字段,例如:["field__c": "test] |
attribute | UpdateAttribute | 本次更新的设置 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
String objectApiName = "object_1yO4J__c";
Map updateFields = Maps.of("name", QueryOperator.EQ("主从同时新建1"));
QueryTemplate query = QueryTemplate.AND(Maps.of("name", QueryOperator.EQ("测试")));
String result = Fx.object.update(objectApiName, query, updateFields, UpdateAttribute.builder().build()).result() as String;
log.info(result);
Groovy举例
String objectApiName = "object_1yO4J__c"
QueryTemplate query = QueryTemplate.AND(
["name":QueryOperator.EQ("主从同时新建1")]
)
def result = Fx.object.update(objectApiName, query, ["field__c": "test"], UpdateAttribute.builder().build()).result() as String
log.info(result)
(1).参考QueryOperator
(2).参考UpdateAttribute
注意事项
- 默认上限更新1000条件数据,如果需要更新1000条以上数据,请设置isAllUpdate为true
- 此批量更新耗时较大,1000条数据大约3分钟
- 此接口更新默认调用到业务团队,以保证业务的完整性
- 如果需刷库,可以将runBusiness为false时,请谨慎使用
6. duplicateSearch 获取查重结果
Fx.object.duplicateSearch(<String apiName>, <String type>, <Map data>, <String relatedApiName>, <Integer pageNumber>, <Integer pageSize>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象apiName |
type | String | 查重类型,其中新建、编辑时为“NEW",查重工具时为"TOOL" |
data | Map | 更新、新建数据 |
relatedApiName | String | 有查找关联关系的对象apiName(注:查本对象时不用传) |
pageNumber | Integer | 显示页数 |
pageSize | Integer | 每页条数 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
Map data = Maps.newHashMap();
data.put("object_describe_api_name", "object_227xW__c");
data.put("field_rT3cG__c", "函数测试12");
Map result = Fx.object.duplicateSearch("object_227xW__c", "NEW", data, null, 1, 20).result()
log.info(result);
Groovy举例
Map data = ["object_describe_api_name":"object_227xW__c","field_rT3cG__c":"函数测试12"]
def ret = Fx.object.duplicateSearch("object_227xW__c", "NEW", data, null, 1, 20).result() as Map
log.info(ret)
7. batchUpdate 批量更新某个字段的内容
Fx.object.batchUpdate(<String apiName>, <Map objects>, <List fields>, <BatchUpdateAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objects | Map | 批量更新的数据信息 |
fields | List | 批量更新的字段里列表 |
attribute | BatchUpdateAttribute | 批量更新属性 |
返回值类型
APIResult
返回值说明
返回的数据类型: List
Groovy举例
//批量更新的数据
Map batch = [ '60acc4a2d040a70001886739': [ 'field_5h77a__c': 'test1' ], '60acc482d040a70001886582': [ 'field_5h77a__c': 'test2' ] ]
//指定更新的字段
List fields = ['field_5h77a__c']
def rst = Fx.object.batchUpdate('object_8N0H2__c', batch, fields, BatchUpdateAttribute.builder().build()).result() as List
log.info(rst)
(1).参考BatchUpdateAttribute
注意事项
- 最多支持500条数据
- 该接口不会触发对象业务逻辑(如:判断权限、触发审批流等)。
- fields里面指定的字段必须在objects里存在,如不存在,则表示清空。
- 该接口更新计算、统计、引用字段可能会与后台的计算服务发生并发覆盖的问题,导致计算结果错误,因此不要在fields中指定计算、统计、引用字段更新。
8. directDelete 直接删除数据库数据,不可恢复,这是一个非常危险的操作,谨慎使用
Fx.object.directDelete(<String apiName>, <String dataId>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
dataId | String | 数据ID |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
Fx.object.directDelete("AccountObj", "60057c76a3836900012xxxx").result();
Groovy举例
Fx.object.directDelete("AccountObj","60057c76a3836900012xxxx").result()
9. batchDelete 批量删除数据
Fx.object.batchDelete(<String apiName>, <List objectIds>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectIds | List | 数据ID列表 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
String objectAPIName = "AccountObj";
List objectIds = new ArrayList();
objectIds.add("6310659ef11a408161fbbaa1");
objectIds.add("63243fd69d5de8000144c323");
Fx.object.batchDelete(objectAPIName, objectIds).result();
Groovy举例
Fx.object.batchDelete("AccountObj",["60057c76a383690001243bb4","63243fd69d5de8000144c323"]).result()
注意事项
- 该接口不区分对象是否作废,直接批量彻底删除
10. find FQL查询
Fx.object.find(<String apiName>, <FQLAttribute fqlAttribute>, <SelectAttribute selectAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象ApiName |
fqlAttribute | FQLAttribute | 查询条件,详细说明参考FQLAttribute对象 |
selectAttribute | SelectAttribute | 查询属性,非必填,详细说明参考SelectAttribute |
返回值类型
APIResult
返回值说明
返回的数据类型: QueryResult
Groovy举例
def ret = Fx.object.find("AccountObj", //查询客户对象
FQLAttribute.builder()
.columns(["_id", "name"]) //返回的数据id
.queryTemplate(QueryTemplate.AND(["_id": QueryOperator.EQ("6177cde7a0cb410001930ad0")]))
.build(),
SelectAttribute.builder().build()).result() as QueryResult
log.info(ret)
(1).参考FQLAttribute
(2).参考SelectAttribute
(3).参考QueryOperator
11. findOne FQL查询单条数据,推荐使用该方式进行数据查询
Fx.object.findOne(<String apiName>, <FQLAttribute fqlAttribute>, <SelectAttribute selectAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象ApiName |
fqlAttribute | FQLAttribute | 查询条件,详细说明参考FQLAttribute对象 |
selectAttribute | SelectAttribute | 查询属性,非必填,详细说明参考SelectAttribute |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Groovy举例
def ret = Fx.object.findOne("AccountObj", //查询客户对象
FQLAttribute.builder()
.columns(["_id", "name"]) //返回的数据id
.queryTemplate( QueryTemplate.AND(["_id": QueryOperator.EQ("6177cde7a0cb410001930ad0")] ))
.build(),
SelectAttribute.builder()
.build()).result() as Map;
log.info(ret)
(1).参考FQLAttribute
(2).参考SelectAttribute
(3).参考QueryOperator
12. findById FQL查询单条数据Id
Fx.object.findById(<String apiName>, <String id>, <FQLAttribute fqlAttribute>, <SelectAttribute selectAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象ApiName |
id | String | 数据Id |
fqlAttribute | FQLAttribute | 查询条件,详细说明参考FQLAttribute |
selectAttribute | SelectAttribute | 查询属性,非必填,详细说明参考SelectAttribute |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Groovy举例
def ret = Fx.object.findById("AccountObj", //查询客户对象
"6177cde7a0cb410001930ad0",
FQLAttribute.builder()
.columns(["_id","name"]) //返回的数据id
.build(),
SelectAttribute.builder()
.build()).result() as Map;
log.info(ret)
(1).参考FQLAttribute
(2).参考SelectAttribute
13. findByIds FQL查询数据id匹配的数据集
Fx.object.findByIds(<String apiName>, <List ids>, <FQLAttribute fqlAttribute>, <SelectAttribute selectAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象ApiName |
ids | List | 数据id列表 |
fqlAttribute | FQLAttribute | 查询条件,详细说明参考FQLAttribute |
selectAttribute | SelectAttribute | 查询属性,非必填,详细说明参考SelectAttribute |
返回值类型
APIResult
返回值说明
返回的数据类型: List
Groovy举例
def ret = Fx.object.findByIds("AccountObj", //查询客户对象
["6177cde7a0cb410001930ad0"],
FQLAttribute.builder()
.columns(["_id","name"]) //返回的数据id
.build(),
SelectAttribute.builder()
.build()).result() as List;
log.info(ret)
(1).参考FQLAttribute
(2).参考SelectAttribute
(3).参考QueryOperator
14. select 通过SQL语句查询数据,可以设置是否从db查询,是否查询总数,是否查相关团队等参数
Fx.object.select(<String sql>, <SelectAttribute selectAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
sql | String | 查询数据的sql语句 |
selectAttribute | SelectAttribute | 特殊查询条件,非必填 |
返回值类型
APIResult
返回值说明
返回的数据类型: QueryResult
Java举例
//普通用法
String sql = "select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c>100 limit 10 offset 0;";
def rst = Fx.object.select(sql).result() as QueryResult;
log.info(rst);
//如果需要查询不包含作废数据、返回满足条件的数据总数
String sql1 = "select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c>100 limit 10 offset 0;";
SelectAttribute att = SelectAttribute.builder()
.needInvalid(false)
.build();
QueryResult rst1 = Fx.object.select(sql1, att).result();
log.info(rst1);
//如果是聚合查询,如sum操作,返回结果为List
String sql2 = "select sum(field_wye92__c) from object_u2lTt__c where field_wye92__c>0"
SelectAttribute att2 = SelectAttribute.builder().build()
List rst2 = Fx.object.select(sql2, att2).result() as List
log.info(rst2)
Groovy举例
1. 什么是FQL
FQL是能够在APL里使用的类SQL查询语句,开发人员能够在APL中使用FQL查询企业中的业务数据
2. FQL语法
SELECT
字段名1 [, 字段名2 ...]
[FROM 对象apiName
[WHERE where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
注意项
-不支持select *查询所有字段,只能通过select field1, field2...按需查找相关字段
-limit默认为10,最大值为100,offset默认为0
-使用OR条件需要单独开通,请联系销售人员下订单开通产品:【对象列表筛选支持或】
3. Where条件支持的操作符
-与查询:AND
select name from object_227xW__c where (field_rzv5M__c is null and field_rzv5M__c<= 100) order by _id desc limit 10 offset 0;
-或查询:OR(SQL中AND运算符的优先级高于OR运算符,想要优先执行OR运算符时,需要使用括号)
select name from object_227xW__c where (field_rzv5M__c is null or field_rzv5M__c<= 100) order by _id desc limit 10 offset 0;
-判断相等和不相等:=,!=
select _id, field_rzv5M__c, name from object_227xW__c where field_oc43W__c = '13988523405' limit 10 offset 0;
select _id, field_rzv5M__c, name from object_227xW__c where field_oc43W__c != '13988523405' limit 10 offset 0;
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c = 100 limit 10 offset 0;
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c != 100 limit 10 offset 0;
-大于:>,小于:<select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c>100 limit 10 offset 0;
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c<100 limit 10 offset 0;
-大于或等于:>=,小于或等于:=<select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c>= 100 limit 10 offset 0;
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c<= 100 limit 10 offset 0;
-模糊查询:like,not like,当 like 'xx' 没有放 %时相当于=
select _id, field_rzv5M__c, name from object_227xW__c where field_oc43W__c like '%88523%';
select _id, field_rzv5M__c, name from object_227xW__c where field_oc43W__c like '%88523';
select _id, field_rzv5M__c, name from object_227xW__c where field_oc43W__c like '88523%';
select _id, field_rzv5M__c, name from object_227xW__c where field_oc43W__c not like '%88523%';
-null值判断:is null,is not null
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c is null;
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c is not null;
-数组包含:@>,适用于单选、多选等数据类型为List的字段
select _id, field_D8JyW__c, name from object_227xW__c where field_D8JyW__c @>ARRAY['option1', 'option2'];
-数组有重叠元素:&&,适用于人员多选,部门多选,比如 ARRAY[1,4,3]&&ARRAY[2,1] = true,有重复元素1,ARRAY[1,4,3]&&ARRAY[2] = false 没有重复元素
当查询语句中使用&&和其他操作符的组合时,&&需要加上括号,否则会出现解析错误
例如:select _id, name from object_C0vxo__c where create_time>0 and field_7cQ6y__c&&ARRAY[1000]
需要改成:select _id, name from object_C0vxo__c where create_time>0 and (field_7cQ6y__c&&ARRAY[1000])
select _id from object_C0vxo__c where field_7cQ6y__c&&ARRAY[1000];
-in语句:IN,NOT IN
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c IN (21, 100);
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c not IN (21, 100);
-between语句:BETWEEN AND,NOT BETWEEN AND
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c BETWEEN 21 and 100;
select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c not BETWEEN 21 and 100;
4. 高级用法
-支持字段间的比较,不支持in,between,@>等操作符
select name from AccountObj where last_modified_time>create_time;
select name from AccountObj where name != firstName;
select name from AccountObj where name = firstName;
select name from AccountObj where name<= firstName;
-聚合查询支持聚合函数count/sum/min/max/avg和分组聚合grooup by(不支持having),
聚合函数默认会从ES进行聚合,如果对数据一致性有所要求,请指定使用DB进行聚合
select count(1) from object_227xW__c where field_qC2yp__c is not null
select sum(field_rzv5M__c) from object_227xW__c where field_qC2yp__c is not null group by field_qC2yp__c
select max(field_rzv5M__c) from object_227xW__c where field_qC2yp__c is not null group by field_qC2yp__c
select min(field_rzv5M__c) from object_227xW__c where field_qC2yp__c is not null group by field_qC2yp__c
select avg(field_rzv5M__c) from object_227xW__c where field_qC2yp__c is not null group by field_qC2yp__c
// 多聚合函数和和多group by字段
select avg(field_rzv5M__c), sum(field_rzv5M__c) from object_227xW__c where field_qC2yp__c is not null group by field_qC2yp__c, record_type
-子查询,目前只支持:字段 in/not in (子查询)
select _id, name from object_qe3x1__c where field_4rSu9__c in (select id from object_227xW__c where name = '2021---07--2207')
//嵌套子查询
select _id, name from object_qe3x1__c where field_4rSu9__c in (select id from object_227xW__c where field_09jTD__c in (select id from object_qe3x1__c where name = 'zaishisyice'))
5. 代码案例
注意:Fx.object.select用来普通查询数据时返回值里的data类型是QueryResult,做聚合查询是data的类型是List
//普通用法
String sql = "select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c>100 limit 10 offset 0;"
def rst = Fx.object.select(sql).result() as QueryResult
log.info(rst)
//如果需要查询不包含作废数据、返回满足条件的数据总数
String sql1 = "select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c>100 limit 10 offset 0;"
SelectAttribute att = SelectAttribute.builder()
.needInvalid(false)
.build()
def rst1 = Fx.object.select(sql1, att).result() as QueryResult
log.info(rst1)
(1).参考SelectAttribute
15. select 使用SQL查询大量数据,并做好了分页处理(适用于查全量数据,不支持order by limit操作)
Fx.object.select(<String sql>, <SelectAttribute selectAttribute>, <Consumer consumer>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
sql | String | 通过FQL进行大量数据的查询,每一批会触发一次回调函数(该方法使用_id排序,sql中指定的order by将不生效) |
selectAttribute | SelectAttribute | 查询属性,非必填,详细说明参考SelectAttribute |
consumer | Consumer | java.util.function.Consumer 接口,消费一个数据 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
String sql = "select _id, field_rzv5M__c, name from object_227xW__c where field_rzv5M__c>100";
SelectAttribute att = SelectAttribute.builder()
.build();
Fx.object.select(sql, att, list ->{
log.info(list);
}).result();
Groovy举例
def objectName = 'object_227xW__c'
def searchValue = 100
def sql = "select _id, field_rzv5M__c, name from ${objectName} where field_rzv5M__c>${searchValue}";
Fx.object.select(sql, SelectAttribute.builder().build(), { list->log.info(list);
}).result();
(1).参考SelectAttribute
注意事项
- 该函数适用于查符合条件的全量数据的场景
- 该函数不支持order by操作,不支持limit操作
16. findWithRelated 该函数可以通过查找关联或主从关系,查询相关数据,并且一起返回
Fx.object.findWithRelated(<String apiName>, <String relatedField>, <List criteria>, <Map orderBy>, <Integer limit>, <Integer skip>, <ActionAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 主对象的api名称 / 从对象api名称 |
relatedField | String | 主对象的关联字段 / 从对象的主对象字段 |
criteria | List | 查找条件 |
orderBy | Map | 排序规则 key:按哪个字段排序,字段名称 ;value:1 - 升序,-1 - 降序 |
limit | Integer | 限制查询条数,最大100条,如超过返回100条,使用skip参数分批查询 |
skip | Integer | 跳过多少数据 |
attribute | ActionAttribute | 可选参数 forceQueryFromDB: 是否强制从数据库中查询 |
返回值类型
APIResult
返回值说明
返回的数据类型: QueryResult
Java举例
QueryResult result = Fx.object.findWithRelated(
"object_0uyAd__c",
"field_YjJ6d__c",
Lists.newArrayList(Maps.of("_id", "60868215965b1900014c0d35")), Maps.newHashMap(), 1, 0).result();
log.info(result);
List dataList = (List) result.get("dataList");
dataList.forEach(item ->{
Map data = (Map) item;
log.info(data.get("object_0uyAd__c"));//子对象
log.info(data.get("AccountObj"));//主对象
});
Groovy举例
def result = Fx.object.findWithRelated('object_0uyAd__c', 'field_YjJ6d__c', [["_id":"60868215965b1900014c0d35"]], [:], 1, 0).result() as QueryResult
log.info(result)
注意事项
- 使用该函数做查找关联的时,ApiName给的是主对象的ApiName,并且relatedField是查找关联字段
- 使用该函数做主从查询的时,ApiName给的是从对象的ApiName,并且relatedField是主对象字段
17. remove 作废数据,将数据放入回收站
Fx.object.remove(<String apiName>, <String objectId>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectId | String | 对象实例的ID |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
Map result = Fx.object.remove("AccountObj", "ed47841898054749a2ec9be9e6e5d728").result();
Groovy举例
def rst = Fx.object.remove("AccountObj","ed47841898054749a2ec9be9e6e5d728").result() as Map
18. batchRemove 批量作废业务数据,将数据放入回收站
Fx.object.batchRemove(<String apiName>, <List objectIds>, <RemoveAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 需要作废的对象apiName |
objectIds | List | 需要作废的数据ids |
attribute | RemoveAttribute | 可选参数 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
Fx.object.batchRemove("object_oMTq9__c", Lists.newArrayList("id1", "id2"), attribute).result();
Groovy举例
Fx.object.batchRemove("object_oMTq9__c",["id1", "id2"], RemoveAttribute.builder().build()).result()
(1).参考RemoveAttribute
注意事项
- 只有生命状态为正常的数据才能被作废
19. editTeamMember 覆盖编辑对象团队成员
Fx.object.editTeamMember(<String apiName>, <String objectId>, <List teamMembers>, <Boolean ignoreSendingRemind>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectId | String | 对象实例的ID |
teamMembers | List | 要编辑团队成员的信息的List(key值包括: userID:用户ID; role:添加的团队成员的角色:1-负责人,2-联合跟进人,3-售后服务人员,4-普通成员; permisson:添加的团队成员的权限:1-只读,2-读写 |
ignoreSendingRemind | Boolean | 可选参数,是否不发送提醒,true为不发送,不填时为发送 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
Map result = Fx.object.editTeamMember("AccountObj", "36fd270a986842529445bf3d252cca9b",
Lists.newArrayList(
Maps.of("userId", "1058", "role", 4, "permission", 1),
Maps.of("userId", "1057", "role", 3, "permission", 2))
).result() as Map;
log.info(result)
Groovy举例
def result = Fx.object.editTeamMember("AccountObj","36fd270a986842529445bf3d252cca9b",[["userId":"1058","role":4,"permission":1],["userId":"1057","role":3,"permission":2]]).result() as Map
log.info(result)
20. replaceOutTeamMember 全量替换所有外部成员
Fx.object.replaceOutTeamMember(<String apiName>, <String objectId>, <List outTeamMembers>, <Boolean ignoreSendingRemind>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectId | String | 对象实例的ID |
outTeamMembers | List | 数组参数,参考,参考以下说明 |
ignoreSendingRemind | Boolean | 可选参数,是否不发送提醒,true为不发送,不填时为发送 |
返回值类型
APIResult
(1).参考OutTeamMemberAttribute
21. addTeamMember 添加内部团队成员
Fx.object.addTeamMember(<String apiName>, <String objectId>, <TeamMemberAttribute teamMemberAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectId | String | 对象实例的ID |
teamMemberAttribute | TeamMemberAttribute | 参考以下说明 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
// 添加人员
TeamMemberAttribute employTeamMember = TeamMemberAttribute.createEmployMember(Lists.newArrayList("1027"),
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY);
Fx.object.addTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", employTeamMember).result();
//添加用户组
TeamMemberAttribute groupTeamMember = TeamMemberAttribute.createGroupMember(Lists.newArrayList("6152bd0de3e51c0001ec4de3"),
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY);
Fx.object.addTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", groupTeamMember);
//添加部门
TeamMemberAttribute deptTeamMember = TeamMemberAttribute.createDepartmentMember(Lists.newArrayList("1008"),
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY);
Fx.object.addTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", deptTeamMember);
//添加角色
TeamMemberAttribute roleTeamMember = TeamMemberAttribute.createRoleMember(Lists.newArrayList("00000000000000000000000000000009"),
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY);
Fx.object.addTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", roleTeamMember);
Groovy举例
// 添加人员
def employTeamMember = TeamMemberAttribute.createEmployMember(["1027"],
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY)
Fx.object.addTeamMember("object_qep6N__c","61848edfd9007e00019ee222", employTeamMember).result()
// 添加用户组
def groupTeamMember = TeamMemberAttribute.createGroupMember(["6152bd0de3e51c0001ec4de3"],
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY)
Fx.object.addTeamMember("object_qep6N__c","61848edfd9007e00019ee222", groupTeamMember).result()
// 添加部门
def deptTeamMember = TeamMemberAttribute.createDepartmentMember(["1008"],
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY)
Fx.object.addTeamMember("object_qep6N__c","61848edfd9007e00019ee222", deptTeamMember).result()
// 添加角色
def roleTeamMember = TeamMemberAttribute.createRoleMember(["00000000000000000000000000000009"],
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY)
Fx.object.addTeamMember("object_qep6N__c","61848edfd9007e00019ee222", roleTeamMember).result()
(1).参考TeamMemberAttribute
注意事项
- 不能添加负责人;如果添加的成员包括负责人,则不会修改负责人数据;如果添加的成员在原系统中有重复的则更新该成员
22. addOutTeamMember 添加外部团队成员
Fx.object.addOutTeamMember(<String apiName>, <String objectId>, <OutTeamMemberAttribute outTeamMemberAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectId | String | 对象实例的ID |
outTeamMemberAttribute | OutTeamMemberAttribute | 参考以下说明 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
// 添加外部人员
TeamMemberEmployee teamMemberEmployee = TeamMemberEmployee.builder()
.userId("309175511")
.outTenantId("301185430")
.build();
OutTeamMemberAttribute outEmployTeamMember = OutTeamMemberAttribute.createEmployMember(Lists.newArrayList(teamMemberEmployee),
TeamMemberEnum.Permission.READANDWRITE);
Fx.object.addOutTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", outEmployTeamMember).result();
//添加下游企业
TeamMemberEmployee outTenant = TeamMemberEmployee.builder()
.userId("300012805")
.outTenantId("300012805")
.build();
OutTeamMemberAttribute outTenantTeamMember = OutTeamMemberAttribute.createOutTenantMember(Lists.newArrayList(outTenant),
TeamMemberEnum.Permission.READANDWRITE);
Fx.object.addOutTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", outTenantTeamMember).result();
//添加外部角色
OutTeamMemberAttribute outRoleTeamMember = OutTeamMemberAttribute.createRoleMember(Lists.newArrayList("5d1f28eee4b0896efc933508"),
TeamMemberEnum.Permission.READANDWRITE);
Fx.object.addOutTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", outRoleTeamMember).result();
//添加下游企业组
OutTeamMemberAttribute outTenantGroupTeamMember = OutTeamMemberAttribute.createOutTenantGroupMember(Lists.newArrayList("613880213ed24b000150a713"),
TeamMemberEnum.Permission.READANDWRITE);
Fx.object.addOutTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", outTenantGroupTeamMember).result();
Groovy举例
// 添加外部人员
def teamMemberEmployee = TeamMemberEmployee.builder()
.userId("309175511")
.outTenantId("301185430")
.build()
def outEmployTeamMember = OutTeamMemberAttribute.createEmployMember([teamMemberEmployee], TeamMemberEnum.Permission.READANDWRITE)
Fx.object.addOutTeamMember("object_qep6N__c","61848edfd9007e00019ee222", outEmployTeamMember).result()
// 添加下游企业
def outTenant = TeamMemberEmployee.builder()
.userId("300012805")
.outTenantId("300012805")
.build()
def outTenantTeamMember = OutTeamMemberAttribute.createOutTenantMember([outTenant], TeamMemberEnum.Permission.READANDWRITE)
Fx.object.addOutTeamMember("object_qep6N__c","61848edfd9007e00019ee222", outTenantTeamMember).result()
// 添加外部角色
def outRoleTeamMember = OutTeamMemberAttribute.createRoleMember(["5d1f28eee4b0896efc933508"], TeamMemberEnum.Permission.READANDWRITE)
Fx.object.addOutTeamMember("object_qep6N__c","61848edfd9007e00019ee222", outRoleTeamMember).result()
// 添加下游企业组
def outTenantGroupTeamMember = OutTeamMemberAttribute.createOutTenantGroupMember(["613880213ed24b000150a713"], TeamMemberEnum.Permission.READANDWRITE)
Fx.object.addOutTeamMember("object_qep6N__c","61848edfd9007e00019ee222", outTenantGroupTeamMember).result()
(1).参考OutTeamMemberAttribute
23. deleteTeamMember 删除相关团队
Fx.object.deleteTeamMember(<String apiName>, <List objectIds>, <List teamMembers>, <List outTeamMemberEmployee>, <Boolean ignoreSendingRemind>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectIds | List | 对象实例的IDs |
teamMembers | List | 需要删除的团队成员id集合,默认是人员id list集合,若TeamMemberType参数设置0以外的值时,则为对应类型的id list集合。 |
outTeamMemberEmployee | List | 外部成员列表 |
ignoreSendingRemind | Boolean | 可选参数,是否不发送提醒,true为不发送,不填时为发送 |
返回值类型
APIResult
返回值说明
返回的数据类型: 返回数据类型:Map
Java举例
Fx.object.deleteTeamMember("object_qep6N__c",
Lists.newArrayList("61848edfd9007e00019ee222"),Lists.newArrayList(),
Lists.newArrayList(Maps.of("userId","300012805","outTenantId","")) //外部联系人必须这么给
).result();
Groovy举例
Fx.object.deleteTeamMember("object_qep6N__c",["61848edfd9007e00019ee222"],[],[["userId":"300012805","outTenantId":""]]).result()
24. getTeamMember 获取团队成员
Fx.object.getTeamMember(<String apiName>, <String objectId>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectId | String | 对象实例的ID |
返回值类型
APIResult
返回值说明
返回的数据类型: List <Map>
Java举例
List<Map>result = Fx.object.getTeamMember("AccountObj", "83cf73d957924284a96e9c44ebb333ec").result();
Groovy举例
def rst = Fx.object.getTeamMember("AccountObj","83cf73d957924284a96e9c44ebb333ec").result() as List
log.info(rst)
25. changeOwner 更换数据的负责人
Fx.object.changeOwner(<String apiName>, <String objectId>, <String ownerId>, <ActionAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
objectId | String | 对象实例的ID |
ownerId | String | 要变更的负责人的用户ID |
attribute | ActionAttribute | triggerApprovalFlow:是否触发审批流,默认为true triggerWorkflow:是否触发工作流,默认为true skipFunctionAction:是否跳过前后动作函数,默认为false不跳过 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
Fx.object.changeOwner("AccountObj", "ed47841898054749a2ec9be9e6e5d728", "1001").result();
Groovy举例
Fx.object.changeOwner("AccountObj","ed47841898054749a2ec9be9e6e5d728","1001").result()
26. batchChangeOwner 批量更换负责人
Fx.object.batchChangeOwner(<String apiName>, <List changeData>, <ActionAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
changeData | List | 要变更的负责人的数据ID和用户ID |
attribute | ActionAttribute | triggerApprovalFlow:是否触发审批流,默认为true triggerWorkflow:是否触发工作流,默认为true skipFunctionAction:是否跳过前后动作函数,默认为false不跳过 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
Map changeData1 = Maps.newHashMap();
changeData1.put("objectId", "5f86b47b1bdac00001f2c300");
changeData1.put("ownerId", Lists.newArrayList("-10000"));
Map changeData2 = Maps.newHashMap();
changeData2.put("objectId", "5f86b4a71bdac00001f2d232");
changeData2.put("ownerId", Lists.newArrayList("-10000"));
List arg = Lists.newArrayList(changeData1, changeData2);
Fx.object.batchChangeOwner("object_i66LR__c", arg, ActionAttribute.create()).result();
Groovy举例
Map changeData1 = [
"objectId":"5f86b47b1bdac00001f2c300",
"ownerId":["-10000"]
]
Map changeData2 = [
"objectId":"5f86b4a71bdac00001f2d232",
"ownerId":["-10000"]
]
List arg = [changeData1,changeData2]
Fx.object.batchChangeOwner("object_i66LR__c", arg, ActionAttribute.create()).result()
(1).参考ActionAttribute
27. getOptionName 获取单选/多选业务名称/选项名称
Fx.object.getOptionName(<String objectAPIName>, <String filedAPIName>, <String value>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
objectAPIName | String | 对象的api名称 |
filedAPIName | String | 字段的api名称 |
value | String | 单选/多选的值 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Groovy举例
def rst = Fx.object.getOptionName("AccountObj","lock_status","0").result() as String
log.info(rst)
28. copyByRule 根据映射规则创建数据
Fx.object.copyByRule(<String sourceApiName>, <String sourceId>, <String ruleApiName>, <Map plus>, <Map detailPlus>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
sourceApiName | String | 被映射的对象Api Name |
sourceId | String | 被映射的对象实例的ID |
ruleApiName | String | 映射规则API Name |
plus | Map | 可选参数,主对象数据参数 |
detailPlus | Map | 可选参数,从对象数据参数 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
Map plus = Maps.of("field_ZszsOc", "18800154471");
Map detailValues1 = Maps.of("field_z5AI0c", "data1填充内容");
Map detailValues2 = Maps.of("field_z5AI0c", "data2填充内容");
List detailFillValueList = Lists.newArrayList();
detailFillValueList.add(detailValues1);
detailFillValueList.add(detailValues2);
Map detailPlus = Maps.of("object_6hN1ic", detailFillValueList);
Map result = Fx.object.copyByRule("object_ob2G0__c", "5cedf0137cfed9b33b75ddaa", "map_797K4__c", plus, detailPlus).result();
Groovy举例
Map plus = ["field_ZszsOc": "18800154471"]
List detailFillValueList = [["field_z5AI0c": "data1填充内容"], ["field_z5AI0c": "data2填充内容"]]
Map detailPlus = ["object_6hN1ic": detailFillValueList]
def rst = Fx.object.copyByRule('object_ob2G0__c','5cedf0137cfed9b33b75ddaa','map_797K4__c',plus,detailPlus).result() as Map
注意事项
- 使用本方法创建的数据,可以触发审批流以及工作流
29. lock 对数据进行锁定操作
Fx.object.lock(<String apiName>, <String objectId>, <Boolean cascadeDetail>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectId | String | 对象实例id |
cascadeDetail | Boolean | 是否锁定从对象 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
Fx.object.lock("AccountObj", "e6a338ae8a944cdfb2bae737db1aa12f", true).result();
Groovy举例
Fx.object.lock('AccountObj','e6a338ae8a944cdfb2bae737db1aa12f', true).result()
30. unlock 对数据进行解锁操作
Fx.object.unlock(<String apiName>, <String objectId>, <Boolean cascadeDetail>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectId | String | 对象实例id |
cascadeDetail | Boolean | 是否解锁从对象 |
返回值类型
APIResult
返回值说明
无数据返回
Java举例
Fx.object.unlock("AccountObj", "e6a338ae8a944cdfb2bae737db1aa12f", true).result();
Groovy举例
Fx.object.unlock('AccountObj','e6a338ae8a944cdfb2bae737db1aa12f', true).result()
31. batchLock 对数据进行批量的锁定
Fx.object.batchLock(<String apiName>, <List objectIds>, <Boolean cascadeDetail>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectIds | List | 数据id |
cascadeDetail | Boolean | 是否锁定从对象 |
返回值类型
APIResult
Java举例
Fx.object.batchLock("AccountObj", Lists.newArrayList("e6a338ae8a944cdfb2bae737db1aa12f"), true).result();
Groovy举例
Fx.object.batchLock('AccountObj', ["e6a338ae8a944cdfb2bae737db1aa12f"], true).result()
32. batchUnlock 对数据进行批量的解锁
Fx.object.batchUnlock(<String apiName>, <List objectIds>, <Boolean cascadeDetail>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectIds | List | 数据id |
cascadeDetail | Boolean | 是否解锁从对象 |
返回值类型
APIResult
Java举例
Fx.object.batchUnlock("AccountObj", Lists.newArrayList("e6a338ae8a944cdfb2bae737db1aa12f"), true).result();
Groovy举例
Fx.object.batchUnlock('AccountObj', ["e6a338ae8a944cdfb2bae737db1aa12f"], true).result()
33. merge 对象合并(只支持客户和线索对象)
Fx.object.merge(<String apiName>, <String targetDataId>, <List sourceDataIds>, <Map objectData>, <String source>, <Boolean needMergeRelationObjects>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象apiName |
targetDataId | String | 保留数据id |
sourceDataIds | List | 并后被删除的数据 |
objectData | Map | 合并后更新的字段值 |
source | String | 可选参数,来源的页面类型,默认为list(如需要指定,需要与以下参数一并填写) |
needMergeRelationObjects | Boolean | 可选参数,是否合并相关对象,默认为true |
返回值类型
APIResult
Java举例
String apiName = "LeadsObj";
String targetDataId = "61b9aed9a3c69e0001351a87";
List sourceDataIds = Lists.newArrayList("61b9af07a3c69e000135213f");
Map objectData = Maps.newHashMap();
objectData.put("name", "测试合并10");
objectData.put("mobile", "18840934501");
objectData.put("tel", "18840934501");
objectData.put("url", "www.ceshi44.com");
objectData.put("remark", "测试销售线索1");
objectData.put("source", "2");
objectData.put("marketing_event_id", "618a2e8b869433000198ef41");
objectData.put("leads_pool_id", "2876c6af7815475893bea6092bbffd02");
objectData.put("record_type", "default__c");
objectData.put("close_reason", "");
objectData.put("back_reason", "");
objectData.put("data_own_department", Lists.newArrayList("1001");
objectData.put("mc_exchange_rate", "1.000000");
objectData.put("is_duplicated", false);
objectData.put("data_own_organization", Lists.newArrayList("999999"));
objectData.put("leads_stage_changed_time", 1636873294913L);
Fx.object.merge(apiName, targetDataId, sourceDataIds, objectData).result();
Groovy举例
String apiName = "LeadsObj"
String targetDataId = "61b9aed9a3c69e0001351a87"
List sourceDataIds = ["61b9af07a3c69e000135213f"]
Map objectData = [
"name": "测试合并10",
"mobile": "18840934501",
"tel": "18840934501",
"url": "www.ceshi44.com",
"remark": "测试销售线索1",
"source": "2",
"marketing_event_id": "618a2e8b869433000198ef41",
"leads_pool_id": "2876c6af7815475893bea6092bbffd02",
"record_type": "default__c",
"close_reason": "",
"back_reason": "",
"data_own_department": [
"1001"
],
"mc_exchange_rate": "1.000000",
"is_duplicated": false,
"data_own_organization": [
"999999"
],
"leads_stage_changed_time": 1636873294913,
]
Fx.object.merge(apiName, targetDataId, sourceDataIds, objectData).result()
34. aggregate 对某一字段进行聚合,聚合函数默认会从ES进行聚合,如果对数据一致性有所要求,建议从DB进行聚合(forceQueryFromDB=true)
Fx.object.aggregate(<String apiName>, <Aggregate type>, <List criteria>, <String groupByField>, <FindAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
type | Aggregate | 计算类型; Aggregate.SUM(String fieldApiName) 求和 Aggregate.COUNT() 计算数量 Aggregate.MAX(String fieldApiName) 最大值 Aggregate.MIN(String fieldApiName) 最小值 Aggregate.AVG(String fieldApiName) 平均值 |
criteria | List | 查询条件(和find查询条件使用一样) |
groupByField | String | 聚合条件 |
attribute | FindAttribute | 可选参数 returnRelatedValue 是否返回相关数据id对应的value值(默认false) forceQueryFromDB 是否从DB查询数据(默认false) extendFieldApiNames 需要补充__r的字段apiName |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
APIResult result = Fx.object.aggregate("object_227xW__c", Aggregate.MAX("field_rzv5M__c"),
Lists.newArrayList("field_rzv5M__c", QueryOperator.GT(10)),
"field_qC2yp__c"); //最大值
if (result.isError()) {
log.info(result.message());
} else {
log.info(result.getData());
}
Groovy举例
def (Boolean error, List data,String errorMessage) = Fx.object.aggregate("object_227xW__c", Aggregate.MAX("field_rzv5M__c"), [["field_rzv5M__c":Operator.GT(10)]], 'field_qC2yp__c') //最大值
if(error) {
log.info(errorMessage)
} else {
log.info(data)
}
35. aggregate 按照条件进行聚合函数,聚合函数默认会从ES进行聚合,如果对数据一致性有所要求,建议从DB进行聚合(forceQueryFromDB=true)
Fx.object.aggregate(<String apiName>, <Aggregate type>, <Integer decimalScale>, <List criteria>, <FindAttribute attribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
type | Aggregate | 计算类型;可以为以下几种类型: 求和 Aggregate.SUM(String fieldApiName) 计算数量 Aggregate.COUNT() 最大值 Aggregate.MAX(String fieldApiName) 最小值 Aggregate.MIN(String fieldApiName) |
decimalScale | Integer | 小数保留位数 |
criteria | List | 查询条件 例如:[["name":Operator.LIKE("abc")] |
attribute | FindAttribute | 聚合的属性设置 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
Map rst = Fx.object.aggregate("object_rqa45__c", Aggregate.AVG("field_VE1by__c"), 2,
Lists.newArrayList(Maps.of("name", QueryOperator.LIKE("name"))),
FindAttribute.getDefaultFindAttribute()
).result();
log.info(rst);
Groovy举例
def rst = Fx.object.aggregate("object_rqa45__c", Aggregate.AVG("field_VE1by__c"), 2, [["name":Operator.LIKE("name")], FindAttribute.getDefaultFindAttribute()).result() as Map
log.info(rst)
(1).参考FindAttribute
36. findDescribe 查询对象描述信息,例如字段、单选信息等
Fx.object.findDescribe(<String apiName>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的api名称 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
Map rst = Fx.object.findDescribe("object_qep6N__c").result() as Map;
log.info(rst);
Groovy举例
def rst = Fx.object.findDescribe('object_qep6N__c').result() as Map
log.info(data)
37. getOptionInfo 查询单选、多选、业务类型对应的value
Fx.object.getOptionInfo(<String apiName>, <String fieldAPIName>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
fieldAPIName | String | 对象的字段apiname,可以是单选、多选、或者业务类型 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map 这个map是双向映射规则,例如(label - > value , value - > label)
Java举例
def rst = Fx.object.getOptionInfo("object_i66LR__c","record_type").result();
Groovy举例
def rst = Fx.object.getOptionInfo("object_i66LR__c","record_type").result() as Map
log.info(rst)
38. bulkDelete 批量将回收站数据(状态是已作废)的数据进行删除,该操作无法恢复数据,请谨慎使用
Fx.object.bulkDelete(<String apiName>, <List objectIds>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectIds | List | 数据IDList |
返回值类型
APIResult
Java举例
String objectAPIName = "AccountObj";
List objectIds = Lists.newArrayList("60057c76a383690001243bb4","60057c76a383690001243bb5");
Fx.object.bulkDelete(objectAPIName, objectIds).result();
Groovy举例
Fx.object.bulkDelete("AccountObj", ["60057c76a383690001243bb4", "60057c76a383690001243bb5"]).result()
注意事项
- 批量操作建议一次不要超过20条
39. bulkRecover 恢复已作废的数据
Fx.object.bulkRecover(<String apiName>, <List objectIds>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectIds | List | 数据IDList |
返回值类型
APIResult
Java举例
String objectAPIName = "AccountObj";
List objectIds = Lists.newArrayList("60057c76a383690001243bb4","60057c76a383690001243bb5");
Fx.object.bulkRecover(objectAPIName, objectIds).result();
Groovy举例
Fx.object.bulkRecover("AccountObj", ["60057c76a383690001243bb4", "60057c76a383690001243bb5"]).result()
注意事项
- 批量操作建议一次不要超过20条
40. delete 将回收占数据(状态是已作废)的数据进行删除,该操作无法恢复数据,请谨慎使用
Fx.object.delete(<String apiName>, <String objectId>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象的apiname |
objectId | String | 数据ID |
返回值类型
APIResult
Java举例
String objectAPIName = "AccountObj";
String objectId = "60057c76a383690001243bb4";
Fx.object.delete("AccountObj", objectId).result();
Groovy举例
Fx.object.delete("AccountObj", "60057c76a383690001243bb4").result()
41. getMappingRule 查询映射信息描述
Fx.object.getMappingRule(<String mappingRuleApiName>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
mappingRuleApiName | String | 映射规则API名称 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Java举例
Map rst = Fx.object.getMappingRule("map_ri5oc__c").result();
log.info(rst);
Groovy举例
def rst = Fx.object.getMappingRule("map_ri5oc__c").result() as Map;
log.info(rst)
42. getCascadeOption 获取单选级联关系配置
Fx.object.getCascadeOption(<OptionAttribute optionAttribute>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
optionAttribute | OptionAttribute | apiName 对象apiName fieldApiName 父单选字段apiName optionValue 可选参数,父单选选项值 |
返回值类型
APIResult
返回值说明
返回的数据类型: Map
Groovy举例
def optionAttribute = OptionAttribute.builder()
.apiName("object_qep6N__c")
.fieldApiName("field_16Yl4__c")
.optionValue("C3mG8ou09")
.build()
def rst = Fx.object.getCascadeOption(optionAttribute).result() as Map
log.info(rst)OptionAttribute optionAttribute = OptionAttribute.builder()
.apiName("object_qep6N__c")
.fieldApiName("field_16Yl4__c")
.optionValue("C3mG8ou09")
.build();
Map rst = Fx.object.getCascadeOption(optionAttribute).result();
log.info(rst);
(1).参考OptionAttribute
参考类 com.fxiaoke.functions.tools.CreateAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
triggerApprovalFlow | boolean | 是否触发审批流, 默认触发 |
triggerWorkflow | boolean | 是否触发工作流 ,默认触发 |
skipFunctionAction | boolean | 是否跳过前验证函数,默认为false不跳过 |
designatedCreatedBy | boolean | 是否指定创建人(包含所有从对象都是指定创建人),默认是系统,可以在参数objectData中指定的key: created_by (List <String> ),传入人员的id可以设置创建人 |
specifyTime | boolean | 指定创建时间, 一般使用当前时间, 默认否 |
duplicateSearch | boolean | 是否查重, 元数据接口不使用该字段, 因为元数据底层有实现查重, 默认查重 |
forceQueryFromDB | boolean | 是否强制从数据库中查询, 和老接口对齐, 暂时不区分 |
fillOutOwner | boolean | 是否填充外部负责人, 业务逻辑接口使用, 元数据接口不使用, 默认否 |
skipAfterFunction | boolean | 是否跳过后动作函数, 业务逻辑接口使用, 元数据接口不使用, 默认为false |
calculateDefaultValue | boolean | 是否计算默认值,默认为false |
enableRealTimeCalculateDataAuth | boolean | 是否实时计算数据权限,默认为false |
参考类 com.fxiaoke.functions.tools.UpdateAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
triggerWorkflow | boolean | 是否触发工作流, 默认触发;不支持触发审批流; |
modifiedBySelf | boolean | 是否指定当前用户为修改人;默认为false代表系统更新,更新人也是系统;设置为true代表当前用户更新,更新人是当前用户;可能存在数据权限不足更新失败的情况;不是所有场景都可以获取到当前用户,此时也会默认系统 |
duplicateSearch | boolean | 是否查重, 默认查重 |
isAllUpdate | boolean | 是否更新所有数据, 当为false的时候最多只更新1000条数据,为true的时候不做数量限制, 默认为false |
applyDataPrivilegeCheck | boolean | 是否校验数据权限,默认不校验 |
skipImmutableFieldValidate | boolean | 是否跳过不可变字段验证,默认false;主要应用于上游数据同步到下游时,下游是否可对锁定字段编辑; |
参考类 com.fxiaoke.functions.tools.ActionAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
triggerApprovalFlow | boolean | 是否触发审批流, 默认触发 |
triggerWorkflow | boolean | 是否触发工作流 ,默认触发 |
skipFunctionAction | boolean | 在create、update只控制是否跳过前验证函数,其他的如bulkRemove、changeOwner、batchChangeOwner同时控制跳过前后函数。 |
designatedCreatedBy | boolean | 是否指定创建人(包含所有从对象都是指定创建人),默认是系统,可以在参数objectData中指定的key: created_by (List <String> ),传入人员的id可以设置创建人 |
modifiedBySelf | boolean | 是否指定当前用户为修改人,仅更新接口使用;默认为false代表系统更新,更新人是系统;设置为true代表当前用户更新,更新人是当前用户;可能存在数据权限不足更新失败的情况;不是所有场景都可以获取到当前用户,此时也会默认系统 |
specifyTime | boolean | 指定创建时间,仅创建接口使用,默认为false |
duplicateSearch | boolean | 是否查重,默认为true |
forceQueryFromDB | boolean | 是否强制从数据库中查询,默认为false |
fillOutOwner | boolean | 是否填充外部负责人,默认为false |
skipAfterFunction | boolean | 在create、update控制是否跳过后动作函数,默认为false |
skipImmutableFieldValidate | boolean | 是否跳过不可变字段验证,默认false;主要应用于上游数据同步到下游时,下游是否可对锁定字段编辑; |
1. 快速构造方式,所有属性都是默认值
ActionAttribute.create()
返回值类型
com.fxiaoke.functions.tools.ActionAttribute
Groovy举例:
ActionAttribute attribute = ActionAttribute.create()
2. 构建器构造属性,在闭包中进行属性赋值
ActionAttribute.build(<groovy.lang.Closure closure>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
closure | Closure |
返回值类型
com.fxiaoke.functions.tools.ActionAttribute
Groovy举例:
ActionAttribute.build {
forceQueryFromDB = false
}
参考类 com.fxiaoke.functions.tools.QueryOperator
1. 查询与条件相等的数据
QueryOperator.EQ(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", QueryOperator.EQ("测试")));
Groovy举例:
List criteria = [["name": Operator.EQ("测试")]]
2. 查询与条件不相等的数据
QueryOperator.NE(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", QueryOperator.NE("测试")));
Groovy举例:
List criteria = [["name": Operator.NE("测试")]]
3. 查询比条件大的数据
QueryOperator.GT(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("create_time", QueryOperator.GT(1645427372658)));
Groovy举例:
List criteria = [["create_time": Operator.GT(1645427372658)]]
4. 查询比条件小的数据
QueryOperator.LT(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("create_time", QueryOperator.LT(1645427372658)));
Groovy举例:
List criteria = [["create_time": Operator.LT(1645427372658)]]
5. 查询大于等于条件的数据
QueryOperator.GTE(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("create_time", QueryOperator.GTE(1645427372658)));
Groovy举例:
List criteria = [["create_time": Operator.GTE(1645427372658)]]
6. 查询小于等于条件的数据
QueryOperator.LTE(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("create_time", QueryOperator.LTE(1645427372658)));
Groovy举例:
List criteria = [["create_time": Operator.LTE(1645427372658)]]
7. 模糊匹配字符串内容
QueryOperator.LIKE(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.LIKE("易动纷享")));
Groovy举例:
List criteria = [["name": Operator.LIKE("易动纷享")]]
8. 除模糊匹配字符串内容
QueryOperator.NLIKE(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.NLIKE("易动纷享")));
Groovy举例:
List criteria = [["name": Operator.NLIKE("易动纷享")]]
9. 查询有交集的数据
如数据是[1,2,3],查询条件是[1,4] 则返回(因为有1)
如数据是[1,2,3],查询条件是[4,5] 则不返回
QueryOperator.IN(<java.util.List list>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
list | List | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.IN(Lists.newArrayList("易动", "纷享"))));
Groovy举例:
List criteria = [["name": Operator.IN(["易动", "纷享"])]]
10. 查询无交集的数据
QueryOperator.NIN(<java.util.List list>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
list | List | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.NIN(Lists.newArrayList("易动", "纷享"))));
Groovy举例:
List criteria = [["name": Operator.NIN(["易动", "纷享"])]]
11. 查询数据的数组字段匹配输入条件的子集
如数据是[1,2,3],查询条件是[1,2] 则返回
如数据是[1,2,3],查询条件是[3,4] 则不返回
QueryOperator.CONTAINS(<java.util.List list>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
list | List | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.CONTAINS(Lists.newArrayList("易动", "纷享"))));
Groovy举例:
List criteria = [["name": Operator.CONTAINS(["易动", "纷享"])]]
12. 查询数据的数组字段匹配输入条件的子集之外的数据
如数据是[1,2,3],查询条件是[1,2] 则不返回
如数据是[1,2,3],查询条件是[3,4] 则返回
QueryOperator.NCONTAINS(<java.util.List list>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
list | List | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.NCONTAINS(Lists.newArrayList("易动", "纷享"))));
Groovy举例:
List criteria = [["name": Operator.NCONTAINS(["易动", "纷享"])]]
13. 查询任何匹配数组任一内容的数据
QueryOperator.HASANYOF(<java.util.List list>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
list | List | 数组 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.HASANYOF(Lists.newArrayList("易动", "纷享"))));
Groovy举例:
List criteria = [["name": Operator.HASANYOF(["易动", "纷享"])]]
14. 查询都不在数组内的数据
QueryOperator.NHASANYOF(<java.util.List list>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
list | List | 数组 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.NHASANYOF(Lists.newArrayList("易动", "纷享"))));
Groovy举例:
List criteria = [["name": Operator.NHASANYOF(["易动", "纷享"])]]
15. 查询数据字段(是/否)存在内容的数据
QueryOperator.EXISTS(<boolean exists>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
exists | boolean | 是/否 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.EXISTS(true)));
Groovy举例:
List criteria = [["name": Operator.EXISTS(true)]]
16. 查询以...为开始的数据
QueryOperator.STARTWITH(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.STARTWITH("易动")));
Groovy举例:
List criteria = [["name": Operator.STARTWITH("易动")]]
17. 查询以...为结束的数据
QueryOperator.ENDWITH(<java.lang.Object values>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
values | Object | 内容 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.ENDWITH("易动")));
Groovy举例:
List criteria = [["name": Operator.ENDWITH("易动")]]
18. 查询在...范围内的数据
QueryOperator.BETWEEN(<java.util.List list>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
list | List | 范围数据 |
返回值类型
com.fxiaoke.functions.tools.QueryOperator
Java举例
List criteria = Lists.newArrayList(Maps.of("name", Operator.BETWEEN(Lists.newArrayList(154542372658, 1645427372658))));
Groovy举例:
List criteria = [["name": Operator.BETWEEN([154542372658, 1645427372658])]]
参考类 com.fxiaoke.functions.tools.BatchUpdateAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
triggerWorkflow | Boolean | 是否触发工作流, 默认触发 |
convert2SingleOperation | Boolean | 预制对象存在特殊业务逻辑不支持批量更新,可以通设置参数convert2SingleOperation为true,转为循环单条更新来处理(速度会比较慢);默认false,不转为单条更新;仅预制对象可转为单条更新 |
参考类 com.fxiaoke.functions.model.FQLAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
columns | List | SELECT [字段] |
queryTemplate | QueryTemplate | WHERE [查询条件],详见QueryTemplate说明 |
orderBy | Map | ORDER BY [排序字段] 例如 ["_id":1] |
limit | Integer | LIMIT [查询数量] 默认10,上限100 |
skip | Integer | SKIP [翻页条目] |
参考类 com.fxiaoke.functions.model.SelectAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
filterByDataRight | Boolean | 是否根据数据权限过滤数据(默认false) |
needRelevantTeam | Boolean | 是否需要相关团队,默认否 |
fillExtendInfo | Boolean | 是否需要自动填充__r字段,例如人员信息,默认不填充 |
needCount | Boolean | 是否返回匹配条件的数量总数,默认否 |
searchRichTextExtra | Boolean | 是否返回完整的富文本,默认否 |
needCalculate | Boolean | 查询时是否执行计算字段,默认是 |
needInvalid | Boolean | 是否返回已作废的数据,默认否 |
needQuote | Boolean | 是否实时计算引用字段,默认是 |
calculateCount | Boolean | 是否实时计算统计字段,默认是 |
paginationOptimization | Boolean | 是否执行分页优化,默认否,当需要大量数据分页操作时可以设置为true |
needOptionLabel | Boolean | 是否返回选项名称,默认否,该参数为true会补充单选多选label 放到${字段apiName}__r中 |
convertQuoteForView | Boolean | 是否以页面展示的格式返回引用字段(默认false),该参数主要针对引用单选、多选、布尔、业务类型的字段,默认返回value,设置为true以后,返回的是label,并通过${字段apiName}__v返回value,以及${字段apiName}__o返回其他选项。 |
validateFilterField | Boolean | 是否校验筛选字段,9.15日前默认为false不校验(可手动改为true校验),9.15后默认为true校验(修改为false不生效); |
参考类 com.fxiaoke.functions.tools.RemoveAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
triggerApprovalFlow | Boolean | 是否触发审批流, 默认触发 |
triggerWorkflow | Boolean | 是否触发工作流 ,默认触发 |
skipFunctionAction | Boolean | 是否跳过前后动作函数,目前不分前后动作 |
useCurrentIdentity | Boolean | 是否使用当前用户身份查询数据(默认falses使用系统) |
skipButtonConditions | Boolean | 跳过按钮显示条件校验 |
参考类 com.fxiaoke.functions.tools.OutTeamMemberAttribute
1. 添加外部成员
OutTeamMemberAttribute.createEmployMember(<List teamMemberList>, <Permission permission>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
teamMemberList | List | 添加外部人员列表 |
permission | Permission | TeamMemberEnum.Permission.READONLY //只读 TeamMemberEnum.Permission.READANDWRITE //读写 TeamMemberEnum.Permission.NO_PERMISSION //无权限 |
返回值类型
OutTeamMemberAttribute
Java举例
TeamMemberEmployee teamMemberEmployee = TeamMemberEmployee.builder()
.userId("309175511")
.outTenantId("301185430")
.build();
OutTeamMemberAttribute outEmployTeamMember = OutTeamMemberAttribute.createEmployMember(
Lists.newArrayList(teamMemberEmployee), TeamMemberEnum.Permission.READANDWRITE);
APIResult outEmployTeamResult = Fx.object.addOutTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", outEmployTeamMember);
log.info(outEmployTeamResult);
Groovy举例:
def teamMemberEmployee = TeamMemberEmployee.builder()
.userId("309175511")
.outTenantId("301185430")
.build()
OutTeamMemberAttribute outEmployTeamMember = OutTeamMemberAttribute.createEmployMember([teamMemberEmployee], TeamMemberEnum.Permission.READANDWRITE)
def outEmployTeamResult = Fx.object.addOutTeamMember("object_qep6N__c","61848edfd9007e00019ee222", outEmployTeamMember)
log.info(outEmployTeamResult)
2. 添加下游企业
OutTeamMemberAttribute.createOutTenantMember(<List teamMemberList>, <Permission permission>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
teamMemberList | List | 下游企业列表 |
permission | Permission | TeamMemberEnum.Permission.READONLY //只读 TeamMemberEnum.Permission.READANDWRITE //读写 TeamMemberEnum.Permission.NO_PERMISSION //无权限 |
返回值类型
OutTeamMemberAttribute
Java举例
TeamMemberEmployee teamMemberEmployee = TeamMemberEmployee.builder()
.userId("309175511")
.outTenantId("301185430")
.build();
OutTeamMemberAttribute outEmployTeamMember = OutTeamMemberAttribute.createOutTenantMember(
Lists.newArrayList(teamMemberEmployee), TeamMemberEnum.Permission.READANDWRITE);
APIResult outEmployTeamResult = Fx.object.addOutTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", outEmployTeamMember);
log.info(outEmployTeamResult);
Groovy举例:
def outTenant = TeamMemberEmployee.builder()
.userId("300012805")
.outTenantId("300012805")
.build()
OutTeamMemberAttribute outTenantTeamMember = OutTeamMemberAttribute.createOutTenantMember([outTenant], TeamMemberEnum.Permission.READANDWRITE)
def outTenantTeamResult = Fx.object.addOutTeamMember("object_qep6N__c","61848edfd9007e00019ee222", outTenantTeamMember)
log.info(outTenantTeamResult)
3. 添加外部角色
OutTeamMemberAttribute.createRoleMember(<List userIds>, <Permission permission>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
userIds | List | 角色Id列表 |
permission | Permission | TeamMemberEnum.Permission.READONLY //只读 TeamMemberEnum.Permission.READANDWRITE //读写 TeamMemberEnum.Permission.NO_PERMISSION //无权限 |
返回值类型
OutTeamMemberAttribute
Java举例
OutTeamMemberAttribute outRoleTeamMember = OutTeamMemberAttribute.createRoleMember(
Lists.newArrayList("5d1f28eee4b0896efc933508"),
TeamMemberEnum.Permission.READANDWRITE);
APIResult outRoleTeamResult = Fx.object.addOutTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", outRoleTeamMember);
log.info(outRoleTeamResult);
Groovy举例:
OutTeamMemberAttribute outRoleTeamMember = OutTeamMemberAttribute.createRoleMember(["5d1f28eee4b0896efc933508"], TeamMemberEnum.Permission.READANDWRITE)
def outRoleTeamResult = Fx.object.addOutTeamMember("object_qep6N__c","61848edfd9007e00019ee222", outRoleTeamMember)
log.info(outRoleTeamResult)
4. 添加下游企业组
OutTeamMemberAttribute.createOutTenantGroupMember(<List userIds>, <Permission permission>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
userIds | List | 企业组 |
permission | Permission | TeamMemberEnum.Permission.READONLY //只读 TeamMemberEnum.Permission.READANDWRITE //读写 TeamMemberEnum.Permission.NO_PERMISSION //无权限 |
返回值类型
OutTeamMemberAttribute
Java举例
OutTeamMemberAttribute outTenantGroupTeamMember = OutTeamMemberAttribute.createOutTenantGroupMember(
Lists.newArrayList("613880213ed24b000150a713"),
TeamMemberEnum.Permission.READANDWRITE);
APIResult outTenantGroupResult = Fx.object.addOutTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", outTenantGroupTeamMember);
log.info(outTenantGroupResult);
Groovy举例:
OutTeamMemberAttribute outTenantGroupTeamMember = OutTeamMemberAttribute.createOutTenantGroupMember(["613880213ed24b000150a713"], TeamMemberEnum.Permission.READANDWRITE)
def outTenantGroupResult = Fx.object.addOutTeamMember("object_qep6N__c","61848edfd9007e00019ee222", outTenantGroupTeamMember)
log.info(outTenantGroupResult)
参考类 com.fxiaoke.functions.tools.TeamMemberAttribute
1. 添加内部成员
TeamMemberAttribute.createEmployMember(<java.util.List<java.lang.String> teamMembers>, <com.fxiaoke.functions.enums.TeamMemberEnum.Role role>, <com.fxiaoke.functions.enums.TeamMemberEnum.Permission permission>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
teamMembers | List | 员工IDList |
role | Role | TeamMemberEnum.Role.OWNER //负责人 TeamMemberEnum.Role.FOLLOWER //联合跟进人 TeamMemberEnum.Role.SERVICE_STAFF //售后服务人员 TeamMemberEnum.Role.NORMAL_STAFF //普通成员 TeamMemberEnum.Role.NOT_EXIST //不在其中 |
permission | Permission | TeamMemberEnum.Permission.READONLY //只读 TeamMemberEnum.Permission.READANDWRITE //读写 TeamMemberEnum.Permission.NO_PERMISSION //无权限 |
返回值类型
com.fxiaoke.functions.tools.TeamMemberAttribute
Java举例
TeamMemberAttribute employTeamMember = TeamMemberAttribute.createEmployMember(
Lists.newArrayList("1027"),
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY);
//employTeamMember.setIgnoreSendingRemind(true) // 可选参数,是否忽略发送CRM提醒。默认false
//employTeamMember.setRealtime(true) // 可选参数,是否实时生效。默认false
APIResult employTeamResult = Fx.object.addTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", employTeamMember);
log.info(employTeamResult);
Groovy举例:
def employTeamMember = TeamMemberAttribute.createEmployMember(["1027"], TeamMemberEnum.Role.NORMAL_STAFF, TeamMemberEnum.Permission.READONLY)
//employTeamMember.setIgnoreSendingRemind(true) // 可选参数,是否忽略发送CRM提醒。默认false
//employTeamMember.setRealtime(true) // 可选参数,是否实时生效。默认false
def employTeamResult = Fx.object.addTeamMember("object_qep6N__c","61848edfd9007e00019ee222", employTeamMember)
log.info(employTeamResult)
2. 添加用户组成员
TeamMemberAttribute.createGroupMember(<java.util.List<java.lang.String> teamMembers>, <com.fxiaoke.functions.enums.TeamMemberEnum.Role role>, <com.fxiaoke.functions.enums.TeamMemberEnum.Permission permission>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
teamMembers | List | 用户组IDList |
role | Role | TeamMemberEnum.Role.OWNER //负责人 TeamMemberEnum.Role.FOLLOWER //联合跟进人 TeamMemberEnum.Role.SERVICE_STAFF //售后服务人员 TeamMemberEnum.Role.NORMAL_STAFF //普通成员 TeamMemberEnum.Role.NOT_EXIST //不在其中 |
permission | Permission | TeamMemberEnum.Permission.READONLY //只读 TeamMemberEnum.Permission.READANDWRITE //读写 TeamMemberEnum.Permission.NO_PERMISSION //无权限 |
返回值类型
com.fxiaoke.functions.tools.TeamMemberAttribute
Java举例
TeamMemberAttribute employTeamMember = TeamMemberAttribute.createEmployMember(
Lists.newArrayList("1027"),
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY);
//employTeamMember.setIgnoreSendingRemind(false) // 可选参数,是否忽略发送CRM提醒。默认false
//employTeamMember.setRealtime(false) // 可选参数,是否实时生效。默认false
APIResult employTeamResult = Fx.object.addTeamMember(
"object_qep6N__c",
"61848edfd9007e00019ee222",
employTeamMember);
log.info(employTeamResult);
Groovy举例:
def employTeamMember = TeamMemberAttribute.createEmployMember(["1027"], TeamMemberEnum.Role.NORMAL_STAFF, TeamMemberEnum.Permission.READONLY)
//employTeamMember.setIgnoreSendingRemind(true) // 可选参数,是否忽略发送CRM提醒。默认false
//employTeamMember.setRealtime(true) // 可选参数,是否实时生效。默认false
def employTeamResult = Fx.object.addTeamMember("object_qep6N__c","61848edfd9007e00019ee222", employTeamMember)
log.info(employTeamResult)
3. 添加部门成员
TeamMemberAttribute.createDepartmentMember(<java.util.List<java.lang.String> teamMembers>, <com.fxiaoke.functions.enums.TeamMemberEnum.Role role>, <com.fxiaoke.functions.enums.TeamMemberEnum.Permission permission>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
teamMembers | List | 部门IDList |
role | Role | TeamMemberEnum.Role.OWNER //负责人 TeamMemberEnum.Role.FOLLOWER //联合跟进人 TeamMemberEnum.Role.SERVICE_STAFF //售后服务人员 TeamMemberEnum.Role.NORMAL_STAFF //普通成员 TeamMemberEnum.Role.NOT_EXIST //不在其中 |
permission | Permission | TeamMemberEnum.Permission.READONLY //只读 TeamMemberEnum.Permission.READANDWRITE //读写 TeamMemberEnum.Permission.NO_PERMISSION //无权限 |
返回值类型
com.fxiaoke.functions.tools.TeamMemberAttribute
Java举例
TeamMemberAttribute deptTeamMember = TeamMemberAttribute.createDepartmentMember(
Lists.newArrayList("1008"),
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY);
//deptTeamMember.setIgnoreSendingRemind(true) // 可选参数,是否忽略发送CRM提醒。默认false
//deptTeamMember.setRealtime(true) // 可选参数,是否实时生效。默认false
APIResult deptTeamResult = Fx.object.addTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", deptTeamMember);
log.info(deptTeamResult);
Groovy举例:
def deptTeamMember = TeamMemberAttribute.createDepartmentMember(["1008"], TeamMemberEnum.Role.NORMAL_STAFF, TeamMemberEnum.Permission.READONLY)
//deptTeamMember.setIgnoreSendingRemind(true) // 可选参数,是否忽略发送CRM提醒。默认false
//deptTeamMember.setRealtime(true) // 可选参数,是否实时生效。默认false
def deptTeamResult = Fx.object.addTeamMember("object_qep6N__c","61848edfd9007e00019ee222", deptTeamMember)
log.info(deptTeamResult)
4. 添加角色成员
TeamMemberAttribute.createRoleMember(<java.util.List<java.lang.String> teamMembers>, <com.fxiaoke.functions.enums.TeamMemberEnum.Role role>, <com.fxiaoke.functions.enums.TeamMemberEnum.Permission permission>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
teamMembers | List | 员工ID列表 |
role | Role | TeamMemberEnum.Role.OWNER //负责人 TeamMemberEnum.Role.FOLLOWER //联合跟进人 TeamMemberEnum.Role.SERVICE_STAFF //售后服务人员 TeamMemberEnum.Role.NORMAL_STAFF //普通成员 TeamMemberEnum.Role.NOT_EXIST //不在其中 |
permission | Permission | TeamMemberEnum.Permission.READONLY //只读 TeamMemberEnum.Permission.READANDWRITE //读写 TeamMemberEnum.Permission.NO_PERMISSION //无权限 |
返回值类型
com.fxiaoke.functions.tools.TeamMemberAttribute
Java举例
TeamMemberAttribute roleTeamMember = TeamMemberAttribute.createRoleMember(
Lists.newArrayList("00000000000000000000000000000009"),
TeamMemberEnum.Role.NORMAL_STAFF,
TeamMemberEnum.Permission.READONLY);
//roleTeamMember.setIgnoreSendingRemind(true) // 可选参数,是否忽略发送CRM提醒。默认false
//roleTeamMember.setRealtime(true) // 可选参数,是否实时生效。默认false
APIResult roleTeamResult = Fx.object.addTeamMember("object_qep6N__c", "61848edfd9007e00019ee222", roleTeamMember);
log.info(roleTeamResult);
Groovy举例:
def roleTeamMember = TeamMemberAttribute.createRoleMember(["00000000000000000000000000000009"], TeamMemberEnum.Role.NORMAL_STAFF, TeamMemberEnum.Permission.READONLY)
//roleTeamMember.setIgnoreSendingRemind(true) // 可选参数,是否忽略发送CRM提醒。默认false
//roleTeamMember.setRealtime(true) // 可选参数,是否实时生效。默认false
def roleTeamResult = Fx.object.addTeamMember("object_qep6N__c","61848edfd9007e00019ee222", roleTeamMember)
log.info(roleTeamResult)
参考类 com.fxiaoke.functions.tools.FindAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
returnRelatedValue | Boolean | 是否返回相关数据id对应的value值(默认false) |
forceQueryFromDB | Boolean | 是否从DB查询数据(默认false) |
extendFieldApiNames | List | 需要补充__r的字段apiName |
参考类 com.fxiaoke.functions.model.OptionAttribute
字段说明
参数 | 类型 | 说明 |
---|---|---|
apiName | String | 对象apiName |
fieldApiName | String | 父单选字段apiName |
optionValue | String | 父单选选项值 |