How to preview images from the sub-form entries
If you have an
image field in your application, the uploaded image can be previewed instantly in a pop-up. This allows users to verify their uploads quickly and ensures that they have selected the correct image before finalizing the submission.
In this tutorial, we'll focus on a main form that includes a sub-form with an image field. We'll refer to this sub-form as Upload Images. Additionally, we'll utilize an extra form named Store Images to store the uploaded images temporarily. These temporarily stored images will be presented for previewing through a page, and will be automatically cleared once the form is submitted.
Note: The report from the Store Images form will be published to obtain an encrypted key. This key will be used within a function to facilitate image previewing.
Create forms with the following fields to upload images and temporarily store the uploaded images for previewing.
Form | Form Link Name | Field Type | Field Name | Field Link Name |
Store Image | Store_Image | Image | Temp Image | Temp_Image |
Upload Images | Upload_Images | Subform Image Decision Box Lookup(Store_Image)
| Subform | Subform |
- Create a function to download the image for preview with the following details.

- Add the following script to the Deluge editor. This will get the URL of the image to preview it dynamically.
- string getimage(int id)
- {
- imageRecord = Store_Images[ID = id];
- if(imageRecord.count() > 0)
- {
- //Fetch the image record ID and path.
- imageRecordId = imageRecord.ID;
- imageRecordPath = imageRecord.Temp_Image;
- subStringStart = imageRecordPath.lastIndexOf("image/") + 6;
- subStringEnd = imageRecordPath.lastIndexOf("\" border");
- imagePath = imageRecordPath.subString(subStringStart,subStringEnd);
- img = "https://creator.zohopublic.com/<adminUserName>/<appLinkName>/<reportLinkName>/" + imageRecordId + "/<fieldLinkName>/image-download/<encryptedKey>/" + imagePath;
- }
- return img;
- }
Substitute the variables in the preceding script with pertinent data, as indicated in the table provided below.
- Create a page with a name Image Preview and add the following page variable.
Variable Name | Data Type |
image_preview | string |
- Drag and drop the ZML snippet element into your page.

- Add the following script to the Deluge editor. This script will retrieve the record ID from the page variable input and then pass it to the getImage function for display.
- <%{
- input.image = thisapp.getimage(input.image_preview.toNumber());
- %>
- <panel elementName="Panel">
- <pr width='fill' height='fill'>
- <pc padding='20px' bgColor='#FFFFFF' width='100%' hAlign='center' vAlign='middle'>
- <pr width='auto' height='auto'>
- <pc>
- <image color='#FFFFFF' bgColor='#2D2D2D' width='500px' height='400px' type='weburl' value='<%=input.image%>' size='38px' cornerRadius='0px' iconType='outline' /> </pc>
- </pr>
- </pc>
- </pr>
- </panel>
- <%
- }%>
- Create a workflow to execute on user input of the subform View field to preview the image.

- Add the following script to the Deluge editor.
- if(row.Image != null)
- {
- //add your image to Store_Images
- add_images = insert into Store_Images
- [
- Added_User=zoho.loginuser
- Temp_Image=row.Image
- ];
- //Get last record from Temp_Images
- last_added = Store_Images[ID != 0] sort by Added_Time desc;
- //Populate the images new record ID into the rows look up field
- row.LookupID=last_added.ID;
- //Assigning the specific ID to a variable
- img = Store_Images[ID == row.LookupID].ID;
- if(img != null)
- {
- //opening the page with the record ID and page parameter
- openUrl("#Page:Image_Preview?image_preview=" + img,"popup window","height=auto,width=auto");
- }
- }
- To hide the ID lookup field in the subform, create another workflow on load of the Upload Images form. Set the record event as Created or Edited and name the workflow as Hide field.

- Click Add New Action and enter the following script in the Deluge editor.
- hide SubForm.LookupID;
- To delete the temporarily stored images in the Store Images form, create a workflow on successful submission of the Upload_Images form. Set the record event as Created or Edited and name the workflow as Delete Temp Images.

- Click Add New Action and enter the following script in the Deluge editor.
- delete from Temp_Images[ID != 0];
See How It Works
- openUrl
- Add records