web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Where to place environment-related variable values

(0) ShareShare
ReportReport
Posted on by 61

Hello everyone!

I have a question regarding best practices of storing environment-related variable values. I have two environments: Prod and Sandbox, both utilize GeneratedFilePath variable, which stores the path, where the new generated file will be located. This path is different for two environments and I am qurious where is better to place those values is code?

I haven't found different config areas in app.json file, is it possible to make configuration though config files, or do I need to create some code units, check current env and return proper value?

I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at

    I think it would be best if you created a setup table for your functionality and stored the filepath in that setup table.

    Then you can get that setup when you need it in the rest of your code and it is not hard coded anywhere in case it changes,

  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    8,760 on at

    Hi Johny Be Good 

     

    I will agree to Inge, to use a setup tables as a storage of your variables e.g. setup links, urls, credentials and your requirements.

     

    Even if you install an app from extension marketplace, You will notice that there variable values are placed into their respective table setups.

     

    If you find this useful please give it a like or verify the answer. By this way you can help other members know that the topic has been answered. Have a nice day. Thank you.

     

    Cheers,

  • Verified answer
    YUN ZHU Profile Picture
    95,739 Super User 2025 Season 2 on at

    Hi, you can also get the environment name directly in your method, and then add the condition.

    More details: https://yzhums.com/8271/

    pastedimage1659314880602v1.png

    pastedimage1659314886106v2.png

    Hope this helps as well.

    Thanks.

    ZHU

  • Johny Be Good Profile Picture
    61 on at

    Thanks for all your replies, guys!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans