我正在三星 Galaxy S4 上进行测试。工单详情屏幕上有“拍照”菜单操作。我在另一个屏幕上添加了从 AttachmentHandler.js 调用 launchCameraForPhoto 函数的相同操作,但相机未在此屏幕上启动。调试时会在 AttachmentHandler.js 中抛出 TypeError 异常。如何让相机在除工作订单详细信息之外的其他屏幕上工作?和上下文有关系吗?这是launchCameraForPhoto功能供您参考。在 this._setRecordOwner(self.ui.getCurrentViewControl().lists[0].getResource().getParent()) 处出现错误
launchCameraForPhoto: function(eventContext){
if(SystemProperties.getProperty('si.attach.doclink.doctypes.defpath') == null){
throw new PlatformRuntimeException('doctypesDefpathNotDefined');
return;
}
var self = this;
var createDate = eventContext.application.getCurrentDateTime();
//mover para o set owner
if(eventContext.getCurrentRecord()){
this._setRecordOwner(eventContext.getCurrentRecord());
} else {
this._setRecordOwner(self.ui.getCurrentViewControl().lists[0].getResource().getParent());
}
MediaService.capturePictureAsPromise().then(function(result){
if(result.fullPath == null){
//throw new PlatformRuntimeWarning("cameraCancelled");
}else{
result.createDate =createDate;
self._updateAttachmentResourceWithMediaInfo(result);
}
}).otherwise(function(error){
//self.ui.showMessage(error.message);
});
},