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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to segregate the security roles based on the license?

(0) ShareShare
ReportReport
Posted on by 162

Hi,

I am trying to fetch the security roles based on the licenses. As per my code, I am able to get the roles but what I want is for Team Members - only the roles related to Team members should be there and for Operations only roles related to Operations should be there.

pastedimage1683692535978v1.png 

Please see the attached code. I have got the license value at formdatasource.

SecurityLicenseRole licenseRole,secLicenseRole;
            SecurityRole role, secRole;
            SecurityUserRole userRole,secUserRole;
            SecurityLicenseRoleCopy licenseRoleCopy1;
            UserLicenseType license;
             str strSecRole;

strSecRole = '';
                        while select * from secRole
                            exists join secUserRole
                                 where secRole.RecId == secUserRole.SecurityRole    &&
                                         secUserRole.User == userRole.User
                                
                        {
                       
                            strSecRole    = strFmt("%1%2,",strSecRole,secRole.Name);
                        
                        
                        
                        }

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Harshal Jain,

    Instead of code you can go for inbuilt option available. Go to Extension >> Dynamics 365 >> Addins>> View related objects and licenses for all roles. Clicking on that will show the excel file with role against the licenses.

    Thanks,

    Girish S.

  • Harshal Jain Profile Picture
    162 on at

    HI Girish,

    I am creating the new form where I want this particular data, so I want to fetch as per code.

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Have you looked at the form "SysSecPartRolesForUser" >> Under Datasource >> SecurityLicenseRole >> Init method >> They are calling the DLL file to get the user license against the role. They are using SecurityLicenseRole as a table for storing the details which will get populated by calling this method.

    Try the same way as standard was implemented.

    Thanks,

    Girish S.

  • Harshal Jain Profile Picture
    162 on at

    Hi Girish,

    Thanks for the reply. I looked into the init method of Datasource but could not think on how to apply the solution.

    In short I want to have license with its roles without repetition.

  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    On the init method they are calling the below code.

    DialogService::PopulateSysSecurityRolesWithAggregateLicense(SecurityLicenseRole.getPhysicalTableName(), SysSecurity::GetSecurityRepository());

    My thought was this piece of code will insert the lisence related records into the SecurityLicenseRole table. Also on the top of the form they must be using some references.

    using Microsoft.Dynamics.AX.Security.Management;
    using Microsoft.Dynamics.AX.Security.Management.Querying;
    using Microsoft.Dynamics.AX.Security.Management.UI;

    This is the reference added to call the DLL file which I mentioned in the above code.

    Just implement the same in your custom form. Since the SecurityLisenceRole table is custom table you can use that table also for testing.

    Thanks,

    Girish S.

  • Harshal Jain Profile Picture
    162 on at

    Hi Girish,

    I checked the code on my custom form. It is already using this method in init to fetch the license. I have user, license. What I want is for every license, I want related roles. It might be my approach is not correct to fetch correct role. Kindly check.

  • GirishS Profile Picture
    27,827 Moderator on at

    It must be trial and error method. Using DLL file they are populating the SecurityRole recid with license role in SecurityLicenseRole table. They will have SecurityRole table as a Datasource and view the related role based on that.

    You need to give it a try. I have never implemented this kind of scenario as you need to give it a try on your own.

    Thanks,

    Girish S.

  • André Arnaud de Calavon Profile Picture
    300,911 Super User 2025 Season 2 on at

    Hi Harshal,

    Girish is correct. Once you are able to get the data in the temporary table, you can set a range on the License column and get the related roles.

  • Harshal Jain Profile Picture
    162 on at

    Hi Girish,

    That dll method worked. Thanks a lot.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans