Hi @André Arnaud de Cal... @André Arnaud de Cal...
Thanks Andre, this is really helpful. I have a few questions to make sure I fully understand the different approaches you suggested.
1. Regarding making the allowed roles configurable:
In our case, the new NewRole role is being created specifically to act as the additional/exception role for this scenario. If another user needs this access in the future, we could simply assign “NewRole” to that user alongside their existing role, without changing the X++.
In that case, would you still see an advantage in introducing separate configuration for the allowed roles rather than using the dedicated SPE IT Manager role for this purpose?
2. Regarding organization assignment:
That's a good point. With my current SecurityUserRole query, how would you recommend ensuring that the role assignment is actually effective for the current legal entity? what changes to do in my code?
3. Regarding the two-menu-item approach: which was aslo suggested by @Diego Mancassola
If I understood correctly, I would still need the new “NewRole” role, along with it's duty and privilege and assign that role to the specific users who should retain access when the IDs are populated.
The difference would be that instead of checking NewRole in X++, I would have two menu items with different security and use X++ only to control which one is visible based on the IDs.
If that's correct, what would you see as the main advantage of introducing the second menu item compared with keeping one menu item and checking the additional role/permission in X++ when the IDs are populated? Is the main benefit that the authorization remains within the standard D365FO security framework?
4. Regarding the ID values:
We checked this and one of the two fields is editable, while the other is read-only.
I just wanted to clarify your concern. Our logic is based on the current values of those two fields. Therefore, if one of the IDs is changed or cleared, the record would no longer meet the "IDs populated" condition, so the normal logic would intentionally apply.
Were you assuming that those fields should not be editable at that stage, or were you referring to a different scenario where you would still recommend validating the condition again as part of the actual operation?
--------------
And another note that ITAdmin is custom, it's xxxITAdmin
Thanks @Deepak Agarwal .
One question: in this scenario, the privilege would also be a newly created, dedicated privilege, so it would still be hardcoded in X++ just like the dedicated “NewRole” role.
Could you elaborate on the advantage of checking the privilege rather than the role in this case? Is it mainly because the privilege represents the business permission rather than a particular role, or is there another benefit? and what is the x++ code used to do check privilege instead?