11-24-2018 12:21 PM - edited 11-25-2018 09:26 AM
Hi, similar this post
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.
Solved! Go to Solution.
11-26-2018 12:51 PM
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):
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
11-27-2018
05:01 PM
- last edited
Monday
by
fcaelen
Thank you sturcato, it works.
03-28-2019
06:52 AM
- last edited
Monday
by
fcaelen
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
06-30-2020 06:49 AM
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>
<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>
06-30-2020 07:25 AM
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