Published at: 2025-10-30

4.4 Function Component: Open API Capabilities for Data Intermediate Tables


Custom functions can insert/modify/query the data mapping table

Function example:

Map header=[:] // create data mapping Map param1=[“ployDetailId”:”155bd981457343f291e0edc13776217f”,// policy detail id — if the policy is deleted and recreated, update this value “sourceObjectApiName”:”AccountObj”,// source object apiName — update if the object apiName changes “destObjectApiName”:”BD_Customer.BillHead”,// destination object apiName (virtual) — update if the object apiName changes “sourceDataId”:”sourceDataId123”,// source object data id “destDataId”:”destDataId123666”,// destination object data id “sourceDataName”:”sourceDataName3666”,// source object data name Attribute “destDataName”:”destDataName66”,// destination object data name Attribute “masterDataId”:”sourceMasterDataId”,// source Primary Object data id (if any) “remark”:”remark1341”// remark, “enableUpdateSourceDataId”: false // allow updating the source data id, default: false ]; def result1=Fx.proxy.callAPI(“erp.syncData.createSyncDataMapping”,header,param1); //[false, HttpResult(statusCode=200, content={“errCode”:”s106240000”,”errMsg”:”成功”}, bytes=null), ] s106240000 = success, others = failure log.info(result1)

Update destination data id based on source object data id

Map param2=[“sourceObjectApiName”:”AccountObj”,// source object apiName — update if the object apiName changes

“destObjectApiName”:”BD_Customer.BillHead”,// destination object apiName (virtual) — update if the object apiName changes

“sourceDataId”:”sourceDataId123”,// source object data id

“destDataId”:”destDataId123666”]// destination object data id

def result2=Fx.proxy.callAPI(“erp.syncData.updateSyncDataMapping”,header,param2);

//[false, HttpResult(statusCode=200, content={“errCode”:”s106240000”,”errMsg”:”成功”}, bytes=null), ] s106240000 = success, others = failure

log.info(result2)

Check whether a source object data id has an existing mapping

Map param3=[“sourceObjectApiName”:”AccountObj”,// source object apiName — update if the object apiName changes

“destObjectApiName”:”BD_Customer.BillHead”,// destination object apiName (virtual) — update if the object apiName changes

“sourceDataId”:[“sourceDataId123”]]// source object data ids, List

// To check whether a destination object data id has a mapping, change sourceDataId to destDataId. If both are provided, only sourceDataId will be used.

def result3=Fx.proxy.callAPI(“erp.syncData.getSyncDataMappingBySourceDataId”,header,param3);

// [false, HttpResult(statusCode=200, content={“data”:{“sourceDataId123”:

//{“sourceDataId”:”sourceDataId123”,”isCreated”:true,”destDataId”:”destDataId123666”,”sourceDataName”:”sourceDataName1233”,”updateTime”:1611047455451,”lastSyncStatus”:6,

//”destDataName”:”destDataName123”,”destTenantId”:”81138”,”sourceObjectApiName”:”AccountObj”,”destObjectApiName”:”BD_Customer.BillHead”,”sourceTenantId”:”81138”,

//”statusName”:”新增成功”,”id”:”aa46ed320312476485e932a1ca4b4263”,”lastSyncDataId”:”92c86fb175254e54b990bd86b6ce1145”,”status”:1}}, “errCode”:”s106240000”,”errMsg”:”成功”}, bytes=null), ]

// s106240000 = success, others = failure

// data is a Map storing mapped records. Key = sourceDataId, value = existing mapping details.

log.info(result3)

Custom function: delete intermediate mapping table

The deleted intermediate records will be logged in the integration flow Report.

// Required: source object apiName. For ERP objects, provide the intermediate object apiName. // When deleting a Primary Object, its Sub-objects are deleted together and the operation is recorded in the operation Report def sourceObjectApiName = “BD_MATERIAL.BillHead”; // Required: destination object apiName. For ERP objects, provide the intermediate object apiName def destObjectApiName = “ProductObj”; // Required: sync direction crm->erp : 1 erp->crm : 2

def syncDirection = 1; // sourceDataIds and destDataIds cannot both be empty // sourceDataIds: list of source object ids; destDataIds: list of destination object ids def sourceDataIds = [“20230316-000014”]

// This type triggers ERP-to-CRM synchronization, using CRM data ids def type = “deleteDataMapping” def params = [“sourceObjectApiName”:sourceObjectApiName, “destObjectApiName”:destObjectApiName, “sourceDataIds”:sourceDataIds, “syncDirection”:syncDirection] def arg = [“type”:type, “params”:Fx.json.toJson(params)] def ret = Fx.proxy.callAPI(“erp.syncData.executeCustomFunction”, [:], arg) // Synchronization result handling: log.info(ret)

Custom function: create ERP field mapping table (system field mapping, employee mapping)

// channel valid values: ERP_K3CLOUD,ERP_SAP,ERP_U8,OA,STANDARD_CHANNEL // “dataType”:”employee” indicates the entry is a person // dataCenterId is the data center id // fsDataId is the CRM data id. For employees this is the staff id, not the CRM person object id. // erpDataId is the ERP data id // fsDataName is the CRM data name Attribute // erpDataName is the ERP data name

Map data = [“dataCenterId”:”data center id”, “channel”:”ERP_K3CLOUD”,”dataType”:”employee”, “fsDataId”:”fsDataId”,”fsDataName”:”fsDataName”,”erpDataId”:”erpDataId”,”erpDataName”:”erpDataName”]; def ret = Fx.proxy.callAPI(“erp.syncData.createErpfieldmapping”, [:], data); // Synchronization result handling: log.info(ret)

Custom function: query ERP field mapping table (system field mapping, employee mapping)

// System field mapping, employee mapping // connector id, data center id def dataCenterId = “xxxx”; // Query types: country, province, city, district, category, employee, employee_oa def dataType = “employee”; // fsDataId and erpDataId cannot both be empty. If both are provided, fsDataId is used. If fsDataId is empty, erpDataId is used. def fsDataId = [“zzzz”] def erpDataId = [“xxx”] def type = “queryFieldMapping” def params = [“dataCenterId”:dataCenterId, “dataType”:dataType, “fsDataId”:fsDataId, “erpDataId”:erpDataId] def arg = [“type”:type, “params”:Fx.json.toJson(params)] def ret = Fx.proxy.callAPI(“erp.syncData.executeCustomFunction”, [:], arg) // Synchronization result handling: log.info(ret)

Submit Feedback