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
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.
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
It’s related to ax2012
Hi Mav,
Is this a question that is related to D365FO or AX2012?
Best regards,
Ludwig
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
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.
Martin Dráb
456
Most Valuable Professional
Abhilash Warrier
310
Saalim Ansari
261