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.
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); }
Hi Girish,
That dll method worked. Thanks a lot.
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.
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.
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.
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.
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.
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.
HI Girish,
I am creating the new form where I want this particular data, so I want to fetch as per code.
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.
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156