APL函數(shù)里獲取觸發(fā)函數(shù)的主從數(shù)據(jù)
// 流程后動(dòng)作函數(shù)里面的context.data數(shù)據(jù)并不會(huì)實(shí)時(shí)計(jì)算計(jì)算字段,引用字段等,也不會(huì)查相關(guān)團(tuán)隊(duì)等信息
// 建議有實(shí)時(shí)獲取計(jì)算引用字段需求的再使用FQL查詢下相關(guān)數(shù)據(jù),F(xiàn)QL里面有參數(shù)控制是否查詢相關(guān)信息
String objectId = context.data["_id"]
String objectApiName = context.data["object_describe_api_name"]
FQLAttribute fqlAtrr = FQLAttribute.builder()
.columns(["_id", "name"]) //需要查詢的字段
.build()
SelectAttribute selectAtrr = SelectAttribute.builder()
.needInvalid(false) //是否需要查作廢數(shù)據(jù)
.build()
//查詢主對(duì)象數(shù)據(jù)
def (Boolean error, Map objectData, String message) = Fx.object.findById(objectApiName, objectId, fqlAtrr, selectAtrr)
if (error) {
log.info("error:" + message)
}
log.info(objectData)
//如果有從對(duì)象數(shù)據(jù)也可以查詢從數(shù)據(jù)
QueryTemplate query = QueryTemplate.AND(
["field_57s3W__c": QueryOperator.EQ(objectId)] //主從關(guān)系字段
)
FQLAttribute fqlAtrr2 = FQLAttribute.builder()
.queryTemplate(query)
.columns(["_id", "name"])
.build()
def (Boolean err2, QueryResult result, String message2) = Fx.object.find("object_adev4__c", fqlAtrr2, selectAtrr)
if (err2) {
log.info("find object_adev4__c error:" + message2)
}
log.info(result)
List dataList = result["dataList"] as List
dataList.each { it ->
log.info(it["name"])
}