Run some code as different user rights in D365 X++
we can define the user in parameter form where we define the user whose rights we want to use. otherwise we can run it as an admin public static void main(Args _args) { FormRun fr = _args.caller(); FormDataSource fds; RunAsPermission perm; UserId runAsUser; SysUserInfo userInfo; if(CustomParrameter::Find().UserId) { userInfo = SysUserInfo::find(CustomParrameter::Find().UserId); }else { userInfo = SysUserInfo::find("Admin"); } runAsUser = userInfo.Id; perm ...