Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Check Environment Country

Posted on by 207
How can I find the environment country via AL?
 
GetApplicationFamily() gives the base app W1
 
  • Mohana Yadav Profile Picture
    Mohana Yadav 48,719 Super User on at
    Check Environment Country
    Makes sense.
    It may not work for localizations that use W1 as base.
  • AJ-05070558-0 Profile Picture
    AJ-05070558-0 25 on at
    Check Environment Country
    Hi Mohana,
     
    I tested as you suggested but I am getting W1
     
    GetApplicationFamily() or ApplicationVersion() is good for 22 countries but when you have base W1 then it does not work.
     
    Thank you
    Ajay Jain
     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 63,522 Super User on at
    Check Environment Country
    Hi, Mohana.
    As far as I know, this can only get the version of the Base App, just like codeunit 457 "Environment Information" -> procedure GetApplicationFamily().
    This cannot get the Country Code.
     
     
    Thanks
    ZHU
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 48,719 Super User on at
    Check Environment Country
    Or 
    Simply use below code
    Message(CopyStr(ApplicationSystemConstants.ApplicationVersion(), 1, 2));
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 63,522 Super User on at
    Check Environment Country
    Yes, this is much simpler than using OAuth authentication to get the standard API.
  • AJ-05070558-0 Profile Picture
    AJ-05070558-0 25 on at
    Check Environment Country
    Thank you YUN ZHU, quite impressed with your blogs
    I have used your IP address blog
     
     
  • YUN ZHU Profile Picture
    YUN ZHU 63,522 Super User on at
    Check Environment Country
    As far as I know, using AL can only obtain Microsoft Entra tenant country letter code. But this is not the country of BC environment, it is the entire Entra Tenant.
    codeunit 433 "Azure AD Tenant"
     
    Hope this helps.
    Thanks.
    ZHU
  • Ajay Jain Profile Picture
    Ajay Jain 207 on at
    Check Environment Country
    Thanks for quick answer
     
    I need something to write in codeunit without calling api
     
    I think I just need country code
  • gdrenteria Profile Picture
    gdrenteria 4,646 Super User on at
    Check Environment Country
    Hi
    You can use this.
    Get environments and Get environments by application family
    Business Central Admin Center API - Environments - Business Central | Microsoft Learn
    BR
    GR

Helpful resources

Quick Links

First Dynamics 365 Community Call (CRM Edition)

Don't miss the first D365 Community Call on 7/10!

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 285,642 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,485 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans