Hexagon Geospatial
MENU

M.App Enterprise

Discuss topics with other M.App Enterprise Product pioneers and experts to get the most out of it.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 51
Registered: ‎10-10-2015
Accepted Solution

WorkFlows M.App Enterprise - Show image from db

[ Edited ]

Hi, similar this post 

https://community.hexagongeospatial.com/t5/M-App-Enterprise/Feature-Analyzer-add-image-to-tooltip-fr...

 

But now with Workflows in M.App Enterprise.

I want to show an Image Field in a Form , the image is collected vía Mobile App and stored in the database. 

 

Someone has an example? 

 

Thanks for advance.

 

Staff
Posts: 998
Registered: ‎10-19-2015

Re: WorkFlows M.App Enterprise - Show image from db

hi,

 

I think the image widget supports only images on the file system referenced as URLs. What you can do is to download and open the image stored as a blob in the db. Here is a sample based on what we have built in the mobile labs (basically the images are stored in a separated table connected to the locations):

 

Capture.PNG

 

The tableAction is implemented this way:

 

SC.Media.downloadAndOpen(IG.createFieldDownloadUrl({id:{ROW.id}, form:'ImageForm', fieldName: 'image', openFile:true}))

You need a separated form representing the image table:

 

  <Form name="ImageForm" editable="true" idfield="id" table="images">
    <FormTab name="NewTabPage1" editable="true" visible="true">
      <FormGroup name="imagedetail" editable="true" visible="true">
        <FormField name="id" editable="true" visible="hidden" datatype="string" defaultvaluemode="onload" required="true" persisted="true" saveinsession="false" type="textfield" override="false" />
        <FormFile name="image" editable="true" visible="true" datatype="binary" defaultvaluemode="onload" persisted="true" override="false" multiple="false" filenamefield="description" contenttypefield="image_mimetype" useuniquename="true" />
      </FormGroup>
    </FormTab>
  </Form>

Just a note here: with the image picker in the mobile app we do not store the filename of the image, so you have to provide a way to create a filename on the client side to download the file and open it immediately (in the sampe above I've used the "description" field as file name).

 

HTH,

Stefano

Stefano Turcato
Presale Engineer
Hexagon Geospatial
Contributor
Posts: 51
Registered: ‎10-10-2015

Re: WorkFlows M.App Enterprise - Show image from db

Thank you sturcato, it works. 

 

 

Occasional Contributor
Posts: 11
Registered: ‎05-11-2018

Re: WorkFlows M.App Enterprise - Show image from db

Hi Stefano,

 

I have implemented the above and for the most part it works. But occasionally I am getting a Java.Lang NullPointer exception when clicking the Action button.

 

NullPointerException

 

<Form name="ImageForm" editable="true" idfield="id" table="WMS_STREET_IMAGES">
    <FormTab name="NewTabPage1" editable="true" visible="true">
      <FormGroup name="imagedetail" editable="true" visible="true">
        <FormField name="id" editable="true" visible="hidden" datatype="string" defaultvaluemode="onload" required="true" persisted="true" saveinsession="false" type="textfield" override="false" />
        <FormFile name="image" editable="true" visible="true" datatype="binary" defaultvaluemode="onload" persisted="true" override="false" multiple="false" filenamefield="description" contenttypefield="image_mimetype" useuniquename="true" />
      </FormGroup>
    </FormTab>
  </Form>

<FormTable name="IMAGES" label="IMAGES:" editable="true" visible="true" datatype="number" defaultvaluemode="onload" lov="SQL[SELECT id, image, description, lastupdatetime FROM WMS_STREET_IMAGES WHERE entity_id = (SELECT ID FROM WMS_STREET_SURVEY WHERE ID = {FORM.ID})]" required="false" persisted="false" saveinsession="false" override="false" idfield="id" selectionmode="none" rowcount="6">
          <FormAction name="Photo" editable="true" visible="true" type="row" action="SCRIPT[SC.Media.downloadAndOpen(IG.createFieldDownloadUrl({id:{ROW.id}, form:'ImageForm', fieldName: 'image', openFile:true}))]"/>
		  <FormTableField name="id" label="id" datatype="string" />
          <FormTableField name="description" label="Description" datatype="string" />
          <FormTableField name="lastupdatetime" label="Date" datatype="string" />
        </FormTable>

Image will load but when I try it again or I try another image from the table view, I will get the exception.

 

Have you guys experienced the error?

 

Thanks

Ciaran

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Development Ticket through our Development Ticket Portal.