M.App Enterprise Discussions

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
Frequent Contributor
Posts: 93
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.

 

Erik Salgado Estrada
STIAN, México.
Staff
Posts: 1,127
Registered: ‎10-18-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
Frequent Contributor
Posts: 93
Registered: ‎10-10-2015

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

[ Edited ]

Thank you sturcato, it works. 

Erik Salgado Estrada
STIAN, México.
Contributor
Posts: 27
Registered: ‎05-11-2018

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

[ Edited ]

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.

 

 

<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

Frequent Contributor
Posts: 129
Registered: ‎11-29-2015

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

We are trying to implement the same with the difference that the workflow is within GMSC (16.6). The very first time, the image can be opened. Later, there occurs a nullPointerException.

 

Image-Form:

<Form name="B1_VBZ132_SCHADENBILDER" editable="true" idfield="VBZ132_ID" table="VBZ132_SCHADENBILDER">
        <FormTab name="NewTabPage1" editable="true" visible="true">
        <FormGroup name="bilddetail" editable="true" visible="true">
            <FormField name="VBZ132_ID" editable="true" visible="hidden" datatype="string" defaultvaluemode="onload" required="true" persisted="true" saveinsession="false" type="textfield" override="false" />
            <FormFile name="VBZ132_BILD" editable="true" visible="true" datatype="binary" defaultvaluemode="onload" persisted="true" override="false" multiple="false" filenamefield="VBZ132_BESCHREIBUNG" contenttypefield="VBZ132_BILD_MIMETYPE" useuniquename="true" />
        </FormGroup>
        </FormTab>
    </Form>
 
Table:
Note: does not work with neither IG.downloadAndOpen or SC.Media.[..]
<FormGroup name="B1_GLEISSCHADEN_TAB1_GROUP2" label="Bilder"  > 
         <FormTable name="B1_GLEISSCHADEN_Table1" label=" " idfield="VBZ132_ID" persisted="false" lov="SQL[SELECT VBZ132_ID, VBZ132_BILD, VBZ132_BESCHREIBUNG, VBZ132_BILD_THUMB, VBZ132_BILD_MIMETYPE  FROM VBZ132_SCHADENBILDER WHERE VBZ132_VBZ131_ID={FORM.VBZ131_ID}]">
            <FormTableField name="VBZ132_ID" label="ID:"/>
            <FormTableField name="VBZ132_BESCHREIBUNG" label="Beschreibung:"/>
            <FormTableField name="VBZ132_BILD" label="BILD"/>
            <FormAction name="open" label="Öffnen" action="SCRIPT[IG.downloadAndOpen(IG.createFieldDownloadUrl({id:{ROW.VBZ132_ID}, form:'B1_VBZ132_SCHADENBILDER', fieldName: 'VBZ132_BILD', openFile:true}))]" type="row" image="ig-icon-download" />

</FormTable>
</FormGroup>
How can I fix this?
Thanks,
Hella
 
Staff
Posts: 1,127
Registered: ‎10-18-2015

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

please make sure you have the extension in the filename. The first time this file has the same name as the original file (this explains why it works one time). Beginning with the second time, the temporary file has another name which is based on the original name. More exactly, at the creation of the name of the temporary file it is assumed that the original filename contains ".". In case this doesn't happen then the name of the temporary file will be null

Stefano Turcato
Presale Engineer
Hexagon Geospatial