Implementation Issue with Non-Persistent Entities Retrieving Persistent FileDocuments

0
Hi,   I am new to the Native Mobile world.  We are gonna build NewsApp for Native Mobile. News are gonna be published on web panel. But, users just only need to see News and download or view attachments on device.   First, i tried with changing all domain model to NonPersistent by copying persistent entities. Then i figured it out that obviously, i can not change the filedocuments. It went all wrong.     I want to create an application with no performance issues. To achieve this, I plan to convert the News objects retrieved in the microflow into News_NPA (Non-Persistent) objects. However, I’m not sure how I can access the related NewsAttachment (Persistent) entities when implementing it as described below. Do I need the News object ID to retrieve the corresponding NewsAttachment objects?   Implementation: a sub-microflow that retrieves and synchronizes the FileDocument object to the device. After that, I may use a retrieve action on the client side to access it.   Or, all I need to restrict synchronization by Xpath ? (I dont want my users to wait too long at the beginning of application start)
asked
1 answers
2

Hi Alp, you're heading in the right direction, and your concerns are valid. Let's break it down and get you on a clean, scalable path for your NewsApp using Mendix Native Mobile best practices.

 

Problem Summary:

You're converting News (persistent) to News_NPA (non-persistent) to reduce sync load smart.

 

What You Have:

  • News (Persistent) – Real data from web panel.

  • NewsAttachment (Persistent) – File uploaded, linked to News.

  • News_NPE (Non-Persistent) – Used in Native Mobile to show News (great!).

  • NewsAttachment_NPE (Non-Persistent) – For showing/download file info (also good).

At app start (or when needed):

  • Run a microflow:

    • Retrieve a list of News (limit to 20 or filter).

    • For each one:

      • Create a News_NPE.

      • Set its values (title, publish date, etc.).

      • Optionally check if NewsAttachment exists → Set haveFileDocument = true.

      • You can skip creating NewsAttachment_NPE at this point to save time.

 This gives you a light, fast list on the mobile screen.

 

When user wants to view/download attachment:

  • Call a microflow with the News ID.

  • Microflow:

    • Retrieves News by ID.

    • Retrieves related NewsAttachment.

    • Returns NewsAttachment (FileDocument).

  • Native client:

    • Uses Download or OpenFileDocument to show it

Bonus Tip:

If you want to preview the file name before download:

  • You can add a “Get Attachment Info” microflow that returns a NewsAttachment_NPE with:

    • name and base64 or URL.

 

I hope this one helps you! :)

 

 

 

answered