Skip to main content

Notifications

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?

  • Johny Be Good Profile Picture
    61 on at
    RE: Where to place environment-related variable values

    Thanks for all your replies, guys!

  • Verified answer
    YUN ZHU Profile Picture
    81,424 Super User 2025 Season 1 on at
    RE: Where to place environment-related variable values

    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

  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    644 on at
    RE: Where to place environment-related variable values

    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,

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,021 Moderator on at
    RE: Where to place environment-related variable values

    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,

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,137 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,877 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans