mendix

Basic Mendix app - Images not showing in ImageViewer


I’m brand new (4 days old!) at Mendix, and I’m trying to write a very basic expense application where expenses are entered, a receipt image (JPG) is uploaded for the expense, and they are then sent for approval/rejection via another data grid page. The Domain Model looks like this. Domain Model

The problem is, I’m trying to use an image viewer to view the expense’s associated image but no image appears. I’ve created a Microflow to get the image and display it in an ImageViewer. The Microflow looks like this: MicroFlow

(The middle box is just a message used for debug purposes) The properties for Retrieving the ExpenseReceiptsUpload row is as follows: Get Row Properties

When the user clicks the ‘View Receipt’ button, the view image panel appears, but no image is shown. Below are the properties for the ‘View Receipt’ button: View Receipt Button Properties Note that I am calling the correct GetImageMicroflow microflow.

The layout for the Image Viewer Object is as follows: Image Viewer Object

Why are the images not appearing? I assume it has something to do with the association between my Expenses entity and my ExpensesReceiptsUpload entity but I feel like I’ve tried everything I can think of but I cannot get it to work! Any words of wisdom would be greatly appreciated!!!


Solution

  • The association needs to be set during the save (commit) action or during the create action. So when you have the Microflow Action Create ExpensesReceiptsUpload you need to set the association to the Expenses object, when the object is committed this will be saved.

    Add this by opening the create action or commit action and click add, select the association, and fill in the value (such as $Expenses).

    Since the association is 1-1 you are also allowed to set relation from the Expenses object. But since you probable create Expenses first, and then ExpensesReceiptsUpload, it makes sense to set the value for the association from the Create/Commit action for ExpensesReceiptsUpload, because then the value $Expenses will be available.

    Edit: i noticed you placed a debugger with the expenses ID, does this show an ID, if you change this to output the ExpensesReceiptsUpload id (or any other attribute of that object), you will notice if the object is available or not).