Published at: 2025-10-30
4.4 [Function Module] Data Intermediate Table Open API Capabilities
Custom Functions for Inserting/Modifying/Querying Data Mapping Tables
Example functions:
groovy
Map header=[:] //Create data mapping
Map param1=["ployDetailId":"155bd981457343f291e0edc13776217f", //Policy detail ID (update if policy is recreated)
"sourceObjectApiName":"AccountObj", //Source object API name (update if changed)
"destObjectApiName":"BD_Customer.BillHead", //Target object API name (virtual, update if changed)
"sourceDataId":"sourceDataId123", //Source object data ID
"destDataId":"destDataId123666", //Target object data ID
"sourceDataName":"sourceDataName3666", //Source object name attribute
"destDataName":"destDataName66", //Target object name attribute
"masterDataId":"sourceMasterDataId", //Primary Object data ID (if applicable)
"remark":"remark1341", //Remarks
"enableUpdateSourceDataId": false //Allow modifying source data ID (default: false)
];
def result1=Fx.proxy.callAPI("erp.syncData.createSyncDataMapping",header,param1); //[false, HttpResult(statusCode=200, content={"errCode":"s106240000","errMsg":"Success"}, bytes=null), ] s106240000 indicates success
log.info(result1)
Updating Target Object Data ID Based on Source Object Data ID
```groovy Map param2=[“sourceObjectApiName”:”AccountObj”, //Source object API name (update if changed)
“destObjectApiName”:”BD_Customer.BillHead”, //Target object API name (virtual, update if changed)
“sourceDataId”:”sourceDataId123”, //Source object data ID
“destDataId”:”destDataId123666”] //Target object data ID
def result2=Fx.proxy.callAPI(“erp.syncData.updateSyncDataMapping”,header,param2);
//[false, HttpResult(statusCode=200, content={“errCode”:”s106240000”,”errMsg”:”Success”}, bytes=null), ] s106240000 indicates success
log.info(result2) ```
Checking Mapping Relationships for Source Object Data ID
```groovy Map param3=[“sourceObjectApiName”:”AccountObj”, //Source object API name (update if changed)
“destObjectApiName”:”BD_Customer.BillHead”, //Target object API name (virtual, update if changed)
“sourceDataId”:[“sourceDataId123”]] //Source object data IDs (List)
//To check target object data IDs, replace sourceDataId with destDataId. If both are provided, only source data ID 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”:”Added successfully”,”id”:”aa46ed320312476485e932a1ca4b4263”,”lastSyncDataId”:”92c86fb175254e54b990bd86b6ce1145”,”status”:1}},”errCode”:”s106240000”,”errMsg”:”Success”}, bytes=null), ]
//s106240000 indicates success
//data is a Map containing existing mappings (key: source data ID, value: mapping details)
log.info(result3) ```
Custom Function for Deleting Mapping Tables
Deleted mapping data will be recorded in the integration flow Report.
```groovy //Required: Source object API name (use intermediate object API name for ERP objects) //When deleting Primary Objects, Sub-objects will be deleted simultaneously and recorded in the Report def sourceObjectApiName = “BD_MATERIAL.BillHead”; //Required: Target object API name (use intermediate object API name for ERP objects) def destObjectApiName = “ProductObj”; //Required: Sync direction (1: CRM→ERP, 2: ERP→CRM)
def syncDirection = 1; //At least one of sourceDataIds or destDataIds must be provided //sourceDataIds: List of source object IDs, destDataIds: List of target object IDs def sourceDataIds = [“20230316-000014”]
//This type triggers ERP→CRM data sync using CRM data ID 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) //Sync result handling: log.info(ret) ```
Custom Function for Creating ERP Field Mapping Tables (System Field Mapping, Employee Mapping)
```groovy //Valid channel values: ERP_K3CLOUD,ERP_SAP,ERP_U8,OA,STANDARD_CHANNEL //”dataType”:”employee” indicates employee mapping //dataCenterId is the data center ID //fsDataId is the CRM data ID (for employees, use employee ID instead of CRM person object data ID) //erpDataId is the ERP data ID //fsDataName is the CRM data name //erpDataName is the ERP data name
Map data = [“dataCenterId”:”DataCenterID”, “channel”:”ERP_K3CLOUD”,”dataType”:”employee”, “fsDataId”:”fsDataId”,”fsDataName”:”fsDataName”,”erpDataId”:”erpDataId”,”erpDataName”:”erpDataName”]; def ret = Fx.proxy.callAPI(“erp.syncData.createErpfieldmapping”, [:], data); //Sync result handling: log.info(ret) ```
Custom Function for Querying ERP Field Mapping Tables (System Field Mapping, Employee Mapping)
groovy
//System field mapping and employee mapping
//Connector ID, Data center ID
def dataCenterId = "xxxx";
//Query type: country/province/city/district/category/employee/employee_oa
def dataType = "employee";
//At least one of fsDataId or erpDataId must be provided (fsDataId takes priority)
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)
//Sync result handling:
log.info(ret)