Retrieve company name a user is working on
iqbalmad
Member Posts: 180
hi
Is there any way i can know which Company a user is working on??
thankx
Is there any way i can know which Company a user is working on??
thankx
0
Comments
-
From the help:COMPANYNAME (Database)
Use this function to return the current company name.
Name := COMPANYNAME0 -
wat if i have several companies???0
-
You could use the User Time Register, with maybe a few tweaks to get exactly what you want.0
-
have u ever done these tweaks??0
-
You can only be logged into one company at a time.iqbalmad wrote:wat if i have several companies???0 -
Even if you have two clients open, each creates its own session. Each session is logged in to a specific company. So there's no way to be logged into multiple companies at the same time.
As the others said, COMPANYNAME is what you're after.0 -
guys,
i think you are not understanding me..
Problem: I have 3 users working on DatabaseX
- Jack (working on company A)
- Terry (working on company
- Natasha (working on company C)
I have created a form linked with Session table.
How do i use COMPANYNAME to know who is working on which company.??0 -
You can't, the session table is a linked to a view on SQL Server. SQL Server doesn't know which company you're logged into.
By the way, COMPANYNAME is not used for that purpose. It returns the company name of the current session, for the user that is currently logged in.0 -
so, as a result, we can't do what i am trying to do?????0
-
i haven't tried it out, but maybe you could log which company a user is in from the CompanyOpen() trigger in CU 1 ?0
-
I am sure that you could do something like this:
Create a table with UserID, LoginTime, LogoutTime (add a date field(s) if you feel this is necessary).
Or as Revolution1210 said...tweak the User Time Register.
Record the UserID, LoginTime when Logging In (CodeUnit 1 > CompanyOpen)
Record the UserID, LogoutTime when Logging Out (CodeUnit 1 > CompanyClose)
This table will exist for each of the 3 companies but create a view in SQL Server that looks at all companies via a Union Query.
The SQL Query would simply be 3 Select statements (1 per company) for all LogoutTime Values = '1/1/1753' (this is equal to 0D in Navision in my version of SQL, not sure what it would be for your installation/locale), tied together via Union statements.
Something like this:
SELECT 'Company A' AS Company, UserID, LoginTime
FROM dbo.[CompanyA$NewTable]
WHERE ([LogoutTime] = CONVERT(DATETIME, '1753-01-01 00:00:00', 102))
UNION
SELECT 'Company B' AS Company, UserID, LoginTime
FROM dbo.[CompanyB$NewTable]
WHERE ([LogoutTime] = CONVERT(DATETIME, '1753-01-01 00:00:00', 102))
UNION
SELECT 'Company C' AS Company, UserID, LoginTime
FROM dbo.[CompanyC$NewTable]
WHERE ([LogoutTime] = CONVERT(DATETIME, '1753-01-01 00:00:00', 102))
Your results would look something like:
CompanyA Jack 10:03 AM
CompanyB Terry 09:20 AM
CompanyC Natasha 08:47 AM
Link your form to the results of the new SQL Server View < I've never linked to a view before but I think this is possible.
If not, there are other ways to pump the information back into Navision (i.e. SQL Stored Procedures).
*****edit ****
I hope this helps.0 -
MBerger wrote:i haven't tried it out, but maybe you could log which company a user is in from the CompanyOpen() trigger in CU 1 ?
I've had tried, it worked well. I've used CompanyOpen and CompanyClose triggers and updated a field like CompanyName in User table.Ufuk Asci
Pargesoft0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

