0

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);
        });
    },

1 Answers1

0

You're right, this code is expecting a certain view layout with a list widget. I think if you just make sure that the currentRecord is set correctly it would trigger the top of that if/else block. Otherwise, you could add another if/else condition, and just make sure you retrieve the correct record based on where you are in the app.

scott dickerson
  • 908
  • 1
  • 5
  • 13