| 纷享销客 | 帮助中心 - 北京易动纷享科技有限责任公司
函数支持将SF附件下载后上传到CRM
//上传文件自定义函数:
String baseUrl="";
String tokenUrl = "/services/oauth2/token?grant_type=password&client_id=【替换】&client_secret=【替换】&username=【替换】&password=【替换】;
String linkedEntityIdUrl = "/services/data/v54.0/query?q=SELECT+ContentDocumentId,ContentDocument.Title,ContentDocument.FileExtension+FROM+ContentDocumentLink+WHERE+LinkedEntityId+=+'%s'";
String contentDocumentIdUrl = "/services/data/v54.0/query?q=SELECT+Id,Title,VersionData+FROM+ContentVersion+WHERE+ContentDocumentId+=+'%s'";
Map header=[:]
Map params1=[:]
params1.put("baseUrl",baseUrl); //基础路径
params1.put("tokenUrl",tokenUrl); //token路径
params1.put("linkedEntityIdUrl",linkedEntityIdUrl); //通过linkedEntityId查询路径
params1.put("contentDocumentIdUrl",contentDocumentIdUrl); //通过contentDocumentId查询路径
params1.put("linkedEntityIdCrmFieldKey","field_tz6ah__c"); //crm对象存储了linkedEntityId值的字段apiname
params1.put("crmObjApiName","AccountObj"); //crm对象apiName
params1.put("crmDataIdList",["63b525cdb211a90001a01117"]); //crm数据id列表
params1.put("fileFieldKey","field_n125H__c"); //附件字段
params1.put("remarkFieldKey","remark"); //下载上传信息备注字段apiName,用来保存处理结果(成功/失败、失败原因)
Map commonParam=["type":"downloadAndUploadFile","params":Fx.json.toJson(params1)];
def result1=Fx.proxy.callAPI("erp.syncData.executeCustomFunction",header,commonParam);
log.info(result1)