To check that user has access to specific privilege in d365 finance and operation use below code
// <summary> /// check user has privilige access /// </summary> /// <param name = "_privilege">privilege identifier as string</param> /// <param name = "_userID">UserId</param> /// <returns>boolean</returns> public static boolean checkUserHasPrivilgeAccess(str _privilege, UserId _userID = curUserId()) { UserInfo userInfo; SecurityUserRole securityUserRole; SecurityPrivilege securityPrivilege; SecurityRolePrivilegeExplodedGraph securityRolePrivilegeExplodedGraph; select firstonly RecId, Id, ObjectId, networkDomain from userInfo exists join securityUserRole where securityUserRole.User == _userID exists join securityRolePrivilegeExplodedGraph where securityRolePrivilegeExplodedGraph.SecurityRole == securityUserRole.SecurityRole exists join securityPrivilege where securityPrivilege.RecId == securityRolePrivilegeExplodedGraph.SecurityPrivilege && securityPrivilege.Identifier == _privilege; return userInfo.RecId; }
You can get privilege identifier from SecurityPrivilege table using privilege name or description
Leave a comment if you have any question.