web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Controlling Security when opening a form through a FormRun object

(0) ShareShare
ReportReport
Posted on by

I am currently opening a form through a button with the following code:

pastedimage1598982785043v2.png

The opened form is simply inheriting the security access from my caller form. For example, if user 1 has delete access to the current form A, clicks a button which opens form B, the user seems to inherit the delete access from A and is able to delete records on form B as well.

I would like to control the security here with more granularity - A and B should be able to have differing security between the two. One option is to modify this code to open through a Menu Item. This then separates the security between a caller and called form but will likely be a more invasive change for me to make.

Is there a way to accomplish separate security access levels while still using a FormRun object?

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    299,353 Super User 2025 Season 2 on at
    RE: Controlling Security when opening a form through a FormRun object

    Hi Ryne,

    Can you tell what datasources/tables are used on both forms? What is the reason that you open a form by coding on a button and not the menu item?

  • Community Member Profile Picture
    on at
    RE: Controlling Security when opening a form through a FormRun object

    Hi Andre. The code to open the form like this has existed for a long time so I am unsure of the reasons it was written like this initially. The tables are custom on both forms. The calling form is a header form and hitting the button opens up a lines form. The business requirement is to now have a user with create access on the header form but delete access on the lines form. The FormRun seems to only consider the security of the calling form though, and opens the lines form with only create access as well - no matter what security it has for the lines table.

    The button can potentially open up a few different line forms so it would be much easier if I could control the security on a FormRun rather than having to restructure this to use Menu Items. Do you know if it is possible to do that?

  • Verified answer
    André Arnaud de Calavon Profile Picture
    299,353 Super User 2025 Season 2 on at
    RE: Controlling Security when opening a form through a FormRun object

    Hi Ryne,

    If the forms are using different tables, you can try to set different table permissions on the privilege or security role.

    It is also possible to call menu items using x logic. Then you can replace the FormRun with e.g. :

       MenuFunction    menuFunction;
       Args            args = new Args();
    
       args.record(RecordToPass);
    
       menuFunction = new MenuFunction(menuitemDispayStr(MenuItem), MenuItemType::Display);
    
       if (menuFunction && menuFunction.checkAccessRights())
       {
           menuFunction.run(args);
       }

  • Community Member Profile Picture
    on at
    RE: Controlling Security when opening a form through a FormRun object

    I tried giving explicit delete table permission for my lines form but that did not work, it seems to always want to take the caller forms security access in this situation. I think my only option is to refactor this to use a MenuFunction like you mentioned. Thanks!

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Controlling Security when opening a form through a FormRun object

    I think it's better to try to use MenuFunction, but there are some cases where it might not be possible.

    In such case, you can still check what kind of access the current user would have to the form's menu item. And based on that, you can change the data source properties AllowEdit, AllowCreate etc in code.

    www.schweda.net/blog_ax.php

  • Community Member Profile Picture
    on at
    RE: Controlling Security when opening a form through a FormRun object

    I have tried to change the datasource property to AllowDelete = true, but this still doesn't enable the delete button if the security permission of the calling form has just Create access. The delete button seems to be disabled no matter what code I write to override it in this scenario. I think the only option for this is a MenuFunction.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,047

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 885 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 592 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans