Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to keep only 1 form instance open

(0) ShareShare
ReportReport
Posted on by

Hi Experts 

I have a custom form , currently a user can open as many instance as he wants by clicking on the menu item.

I want to restrict this in a way that user at any given point can open only 1 instance of the form, please share how do i achieve this.

Thanks

Mav

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,091 on at
    RE: How to keep only 1 form instance open

    Hi Mav,

    In this case, probably, server global cache will work and you can use formname+userId as cache key.

    Alternatively, You can use table where you can store information about the user who already opened the form.

    One form init you can check if there is a record in the table and if it's not, open a form and insert record to the table with current user id, if yes, throw an error that user can't open another instance of the form.

    On form close, you need to remove the record for the current user from the table.

    At least with the table, you have admin access to fix the issue by deleting the record if something goes wrong.

    Also, it would be good to clean the table on AOS startup (Application.starupPost) in case of AOS went down.

  • Mav Profile Picture
    on at
    RE: How to keep only 1 form instance open

    Modal form as described would do this

    "Using this code, nearly every form could be opened in a modal way, so you have to close the form first before you will be able to return to AX."

    Which is not the requirement , user should be able to return to Ax & do multitasking with other forms , however at any given point a user should not be able to open more than 1 instance of the same custom form.

    Thanks

    Mav

  • Sergei Minozhenko Profile Picture
    23,091 on at
    RE: How to keep only 1 form instance open

    Hi Mav,

    Have you checked if the modal form can help you?

    www.axaptapedia.com/Modal_forms

    www.schweda.net/blog_ax.php

  • Mav Profile Picture
    on at
    RE: How to keep only 1 form instance open

    It’s related to ax2012

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at
    RE: How to keep only 1 form instance open

    Hi Mav,

    Is this a question that is related to D365FO or AX2012?

    Best regards,

    Ludwig

  • Mav Profile Picture
    on at
    RE: How to keep only 1 form instance open

    That is having multi company scenario plus other scenarios which are not requried in my simple request which is to ensure that at any given time a user is able to open only 1 instance of the form.

    Found this, can anyone suggest how do i use Singleton for Ax custom form.

    http://thinkinginax.blogspot.com/2014/02/singleton-pattern-in-x.html

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: How to keep only 1 form instance open

    Hi Mav,

    Please take a look at "ReleaseUpdateCockpit" form. Only one instance of the form can be run at a time. It uses a class "ReleaseUpdateRunning" to save the session Id for the form.

    Please check the init method in this form.

    You could try doing something similar to make sure you have only one instance running per session, or else throw an error.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 456 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 310

#3
Saalim Ansari Profile Picture

Saalim Ansari 261

Overall leaderboard

Product updates

Dynamics 365 release plans