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.
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).
Comments
www.NextEqualZero.com
A technical eye on Dynamics NAV
If you mean what company the user opened then that's what COMPANYNAME does...
Am I missing something here :-k
RIS Plus, LLC
MVP - Business Apps
As the others said, COMPANYNAME is what you're after.
My Blog - nav.education
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.??
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.
RIS Plus, LLC
MVP - Business Apps
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.
I've had tried, it worked well. I've used CompanyOpen and CompanyClose triggers and updated a field like CompanyName in User table.
Pargesoft
Well that's bloody easy.
I typed that long drawn out post, but at least it's not for nothing.....I learned something.
Good to know. Thanks MBerger =D>