Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Logged in Database

Posted on by Microsoft Employee

Hi,

I am wondering how to recognize the database in Visual Studio Tools, to which the user is logged in. Please help.

The requirement is when the user clicks on a button, the system should push some data to a customized table in respective company database ie., based on the company to which the user is logged in.

Kind Regards,

Renjan

*This post is locked for comments

  • Suggested answer
    Josh P Profile Picture
    Josh P 2,895 on at
    RE: Logged in Database

    Hi Renjan,

    include:

    using Microsoft.Dexterity.Applications;

    Reference the following static readonly global settings to get what you need:

    // SQL company database name (ie. TWO)

    public static readonly string DataBase = Dynamics.Globals.IntercompanyId.Value;

    // current user's login

    public static readonly string UserID = Dynamics.Globals.UserId.Value;

    // references the ODBC name in registry holding the SQL server instance name

    public static readonly string DataSource = Dynamics.Globals.SqlDataSourceName.Value;

    // company id index

    public static readonly short CompanyId = Dynamics.Globals.CompanyId.Value;

    // gp date

    public static readonly DateTime UserDate = Dynamics.Globals.UserDate.Value;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Logged in Database

    Hi Angel,

    Thank you for the response.

    I am actually looking for something similar to 'UserInfoGet.IntercompanyID' (this is being used in VBA) that I can use in VST.

    Cheers,

    Renjan

  • Suggested answer
    Angel Nuñez Profile Picture
    Angel Nuñez on at
    RE: Logged in Database

    Hi Renjan.

    You can try this:

    SELECT A.USERID, C.CMPNYNAM, C.INTERID

    FROM DYNAMICS..SY01500 C

    JOIN DYNAMICS..ACTIVITY A

    ON C.CMPNYNAM = A.CMPNYNAM

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans