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

Announcements

No record found.

News and Announcements icon
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
    303,730 Super User 2026 Season 1 on at

    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

    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
    303,730 Super User 2026 Season 1 on at

    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

    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,166 Moderator on at

    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

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 460 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans