Sorry, the current permissions prevented the action (Table data modify)

Celicni
Member Posts: 10
This is BC22.
I have made a table to store user login data from all companies. It is a simple table with two fields (field(1; "User ID"; Code[50]), field(2; "Last Login DateTime"; DateTime)).
The table has DataPerCompany = false; so it will record logins for any company.
Here is the code that is giving me the error:
The debugger will randomly error out on the LoginHistory.Modify(False) line with the message (visible only from the event viewer, it doesn't actually show up in the client):
the codeunit has Permissions = tabledata "csa_User_Login_History" = RIMD;
My thinking is it's got something to do with it being a multi-company table, and lacking permissions to modify it in the other companies.
Does anyone have any ideas? It's really annoying to get a breakpoint error randomly.
I have made a table to store user login data from all companies. It is a simple table with two fields (field(1; "User ID"; Code[50]), field(2; "Last Login DateTime"; DateTime)).
The table has DataPerCompany = false; so it will record logins for any company.
Here is the code that is giving me the error:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"System Initialization", 'OnAfterLogIn', '', false, false)] local procedure UpdateLastLoginInfo() var LoginHistory: Record csa_User_Login_History; lastLoginDuration: Duration; begin if UserId <> 'SYSTEM' then if LoginHistory.Get(UserId) then begin lastLoginDuration := CurrentDateTime - LoginHistory."Last Login DateTime"; if (lastLoginDuration > (5 * 60 * 1000)) then begin LoginHistory."Last Login DateTime" := CurrentDateTime; LoginHistory.Modify(false); <------ [b]this line right here errors out[/b] end; end else begin LoginHistory.Init(); LoginHistory."User ID" := UserId; LoginHistory."Last Login DateTime" := CurrentDateTime; LoginHistory.Insert(); end; end;
The debugger will randomly error out on the LoginHistory.Modify(False) line with the message (visible only from the event viewer, it doesn't actually show up in the client):
Error Code:18023831
Sorry, the current permissions prevented the action. (TableData csa_User_Login_History User Login History Modify: Chase Base Application)
the codeunit has Permissions = tabledata "csa_User_Login_History" = RIMD;
My thinking is it's got something to do with it being a multi-company table, and lacking permissions to modify it in the other companies.
Does anyone have any ideas? It's really annoying to get a breakpoint error randomly.
0
Answers
-
https://yzhums.com/17290/
Seems like existing functionality.
If it is very important to you that it registers for all companies, just write code that automatically turns this on when a new user setup record is created, and activate it on all others0 -
This is less about implementing this exact functionality and more about wondering why it errors out at that specific line.
Also, looking at what you linked, not sure it'd fit what they want.0 -
Or the session event table might help.0
-
Or try subscribing on another event. Incompany open?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions