我通过蚂蚁迁移工具将元数据上传到Salesforce托管的应用构建单位时遇到问题。最初的问题出在一个相当大的应用程序中,但我已经将其缩减为2个文件,从而证明了这个问题:一个平台事件和一个发布该事件的Apex类(Web服务)。
objects / CTIDeviceUpdateEvent__e:
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<deploymentStatus>Deployed</deploymentStatus>
<description>Event raised by AVS when the CTI user updates their outbound device.</description>
<eventType>StandardVolume</eventType>
<fields>
<fullName>NewCtiDevice__c</fullName>
<externalId>false</externalId>
<isFilteringDisabled>false</isFilteringDisabled>
<isNameField>false</isNameField>
<isSortingDisabled>false</isSortingDisabled>
<label>NewCtiDevice</label>
<length>64</length>
<required>true</required>
<type>Text</type>
<unique>false</unique>
</fields>
<fields>
<fullName>UserId__c</fullName>
<externalId>false</externalId>
<isFilteringDisabled>false</isFilteringDisabled>
<isNameField>false</isNameField>
<isSortingDisabled>false</isSortingDisabled>
<label>UserId</label>
<precision>18</precision>
<required>true</required>
<scale>0</scale>
<type>Number</type>
<unique>false</unique>
</fields>
<label>CTI Device Update Event</label>
<pluralLabel>CTI Device Update Events</pluralLabel>
</CustomObject>
分类CtiDeviceUpdateWebService.cls
global with sharing class CtiDeviceUpdateWebService {
webservice static void ctiDeviceUpdate(Integer natterboxUserId, String newCtiDeviceRaw) {
List<CTIDeviceUpdateEvent__e> evlist = new List<CTIDeviceUpdateEvent__e> { new CTIDeviceUpdateEvent__e(UserId__c = 1, NewCTIDevice__c = '2001') } ;
// Call method to publish events
List<Database.SaveResult> results = EventBus.publish(evlist);
// Inspect publishing result for each event
for (Database.SaveResult sr : results) {
if (sr.isSuccess()) {
System.debug('Successfully published event.');
} else {
for(Database.Error err : sr.getErrors()) {
System.debug('Error returned: ' +
err.getStatusCode() +
' - ' +
err.getMessage());
}
}
}
}
}
package.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>CustomObject</name>
</types>
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<version>41.0</version>
</Package>
在部署元数据API时,我得到以下结果:
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Af1n00001VmcmHCAR
[sf:deploy] Waiting for server to finish processing the request...
[sf:deploy] Request Status: InProgress
[sf:deploy] Request Status: Failed
BUILD FAILED
/Users/jim.page/Documents/salesforce_ant_43.0/nbavs/build.xml:31:
*********** DEPLOYMENT FAILED ***********
Request ID: 0Af1n00001VmcmHCAR
All Component Failures:
1. classes/CtiDeviceUpdateWebService.cls -- Error: Method does not exist or incorrect signature: void publish(List<CTIDeviceUpdateEvent__e>) from the type EventBus (line 12, column 54)
2. classes/CtiDeviceUpdateWebService.cls -- Error: Invalid type: CTIDeviceUpdateEvent__e (line 9, column 9)
*********** DEPLOYMENT FAILED ***********
我使用托管包的名称空间尝试了不同的API版本,各种事件元数据中的不同设置,而我和google都没主意。
注意-当我仅自己部署平台事件时,部署就可以了,并且可以在构建组织的Setup | Platform Events下看到它。但是,当将Web服务添加到组合中时,部署将失败。从Web服务访问自定义对象没有问题。
还请注意,此代码在开发人员组织中可以正常工作。
答案 0 :(得分:1)
好吧-当我发布这个问题时,我的一位同事给了我答案。平台事件投入生产时,类元数据文件的版本号为41.0之前。