Skip to main content

Notifications

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);
                        
                        
                        
                        }

  • Harshal Jain Profile Picture
    Harshal Jain 162 on at
    RE: How to segregate the security roles based on the license?

    Hi Girish,

    That dll method worked. Thanks a lot.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,160 Super User 2025 Season 1 on at
    RE: How to segregate the security roles based on the license?

    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.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How to segregate the security roles based on the license?

    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.

  • Harshal Jain Profile Picture
    Harshal Jain 162 on at
    RE: How to segregate the security roles based on the license?

    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.

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How to segregate the security roles based on the license?

    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
    Harshal Jain 162 on at
    RE: How to segregate the security roles based on the license?

    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.

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How to segregate the security roles based on the license?

    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
    Harshal Jain 162 on at
    RE: How to segregate the security roles based on the license?

    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
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How to segregate the security roles based on the license?

    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.

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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans