I am testing this on Samsung Galaxy S4. There is 'Take Photo' menu action available on Work Order Details screen. I added the same action that calls launchCameraForPhoto function from AttachmentHandler.js on another screen but camera doesn't launch on this screen. It throws TypeError exception in AttachmentHandler.js when debugged. How do I get the camera working on the other screen except Work order details? Is it anything to do with the context? Here is the launchCameraForPhoto function for your reference. Getting error at 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);
});
},