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

Announcements

No record found.

News and Announcements icon
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?

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 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
    9,128 Super User 2026 Season 1 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
    103,255 Super User 2026 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 715 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 452 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 371 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans