Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL forum
Answered

Help - Accessing Company Switch button in SL Toolbar

Posted on by 125

I've looked in every SL doc I could find but still I am not able to answer what should be a simple question:  how do we access the company switch button in the SL toolbar (upper right hand corner) and read which company is selected from our VBA / VB app?

I need to know if the company has been switched and which company id / company name was selected.

Any help or ideas would be most appreciated.

Thank you!

  • Verified answer
    GG@Imagetag Profile Picture
    GG@Imagetag 125 on at
    RE: Help - Accessing Company Switch button in SL Toolbar

    Ah ... I did see the PES table ... now it is making sense.

    I am customizing standard screens.

    I did tried code similar to yours but it didn't work for me so I will need to dig a little further. why it is not working.

    thank you for setting me onto the right direction

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Help - Accessing Company Switch button in SL Toolbar

    the pes table is located in the system database.  Each screen includes that table as one of the modules and opens it to the record that is just for the user's particular session.  SWIM always refers to tables with a prefix of "b" so that is why, in your code or in a customization you refer to it a bpes.

    You did not indicate whether the screen is a standard SL screen or an SDK developed screen.

    Here is just a simple example of a code segment added via customization manager.  This sample does nothing but demonstrates how to fetch the current company id.

    Private Sub ccustid_Chk(ChkStrg As String, retval As Integer)

    Dim test As String

    test = bpes.cpnyid

    End Sub

  • GG@Imagetag Profile Picture
    GG@Imagetag 125 on at
    RE: Help - Accessing Company Switch button in SL Toolbar

    Rick is it possible I am not using a "bpes" table?  

    I am not finding it anywhere in my database or tempdb.  Perhaps I have to activate?

  • GG@Imagetag Profile Picture
    GG@Imagetag 125 on at
    RE: Help - Accessing Company Switch button in SL Toolbar

    Either way.  I am probably going to stick with the customizations and then call a DLL written in C# to do most of the processing.  So bpes only has the active company (one record) and not the rest of those listed in the Company table?  For some reason I thought it held all of the available companies in it.

    Now that I could work with.  Thank you again!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Help - Accessing Company Switch button in SL Toolbar

    Are you trying to do this with a customization or are you trying to do this in an SDK developed screen?  The bpes table is available to any SL screen and should be to any SDK developed screen.  bpes will also contain just the information for the current session for that user.

    Perhaps you need to explain a bit more about exactly what you are trying to do and the purpose for doing it.  It sounds like you want the current company id so that you can use that in a subsequent query but I cannot tell for sure from your posts so far.

  • GG@Imagetag Profile Picture
    GG@Imagetag 125 on at
    RE: Help - Accessing Company Switch button in SL Toolbar

    Thank you Rick for your response!

    I have seen some code about bpes, but nothing as to which is the active (or new) CpnyID which each screen which I can use to query any table.  Do you have any code samples for determining the currently active CpnyID in the current screen?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Help - Accessing Company Switch button in SL Toolbar

    From a code segment, use the table bpes.  the company ID is in the field called CpnyID and the company name is in the field CpnyName.  bpes is included in every screen.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,564 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,651 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans