Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Easiest way to set con...
Finance forum
Suggested answer

Easiest way to set configuration key and value and retrieve with x++ in form extension

Posted on by 15

Dear forum,

I am just starting with Dynamics 365 F+O and after setting a dev environment and creating an extension, I would like to find a way to 
set and retrieve configuration values, so that later my module can differentiate its functionality per environment.

How is that accomplished in Dynamics 365 F+O form extension?

I would really appreciate any help!

  • Martin Dráb Profile Picture
    Martin Dráb 225,513 Super User on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    Your API setup doesn't belong to the form with dimension values. Create your own table and either put it into an existing parametr form (if suitable), or create a new one. But you'll likely want to familiarize yourself with F&O form patterns, table design and so on, before you start designing your solution.

  • Athankon Profile Picture
    Athankon 15 on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    Thanks again for all the details and valuable hints,

    The form I am extending has a different setup and there are no parameters, will check it out soon and will come back to you.

  • Martin Dráb Profile Picture
    Martin Dráb 225,513 Super User on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    Please at my first reply to get some idea about parameters are handled in F&O. No, there is no generic table that you should use. Design what you need for your purpose, give it a name and set permissions to this table/form. If there was a single generic table, you couldn't configure security in the right way, refer to values in a strongly-typed manner in code and so on.

    You should respect the system you're working with and follow patterns that people are used to use there.

    Not exposing your parameters to users is easy - simply don't give permissions to anyone (except of users in the security role that will maintain this setup).

  • Athankon Profile Picture
    Athankon 15 on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    Thanks, Martin,

    So my guess is that I must store the values manually in the database for each environment. But I do not wish these values to be exposed to the users. Would there already be a generic table for that and an easy way to reference in code with X++?

  • Martin Dráb Profile Picture
    Martin Dráb 225,513 Super User on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    You seem to be giving us a different little piece of every time, but without the whole picture, it's difficult to say what you actually need. You should rather start by explaining the overall requirement.

    But in short, F&O uses the database, not configuration files, to store configuration. Then you put different data to different F&O environment (each environment has its own database).

  • Athankon Profile Picture
    Athankon 15 on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    Hi Martin, thanks again for the updates.

    My question was more towards having a configuration key value pair that I can set and reference in the code of my form extension.

    More specific, I have a class that extends the form I need - [ExtensionOf(formStr(DimensionValueDetails))] - with some event handlers that are executed when CRUD events occur, calling an API.

    For each environment, I want to target a different API:

    FinOps Dev --> API DEV

    FinOps Test --> API Test etc.

    In other applications I would have an app.settings.{environment}.json or a web.{environment}.config

    How can I set and retrieve these kinds of values?

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,513 Super User on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    That's a completely different question.

    Where you can define dimension values depends on the type of dimension.

    For custom dimensions, you can go and add a value (if you have permissions).

    For entity-backed dimensions, you simply create a record through the appropriate form. For example, if you use a project as a dimension, you'll go to project management and create a new project.

  • Athankon Profile Picture
    Athankon 15 on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    Hi Martin,

    Thanks for taking the time to reply to me.

    I navigated to Setup > Warehouse management parameters > and I could see all sections pointing to the table "WHSParameters" you mentioned, but how do I add my custom name value pair in that table?

    My required configuration is for: General ledger > Financial Dimensions > {Active dimension} >Dimension Values

    What could I use in that case?

    Thanks in advance for any help.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,513 Super User on at
    RE: Easiest way to set configuration key and value and retrieve with x++ in form extension

    Data is stored in tables. The basics parameters of each module is in its "Parameters" table, plus there is usually a bunch of tables with other setup.

    For example, if you open Warehouse management module, you'll find these basic parameters under Setup > Warehouse management parameters. The table is called WHSParameters and when you need a values of a parameter, you'll call find() method and read the field. For example:

    WHSParameters::find().EnableVendFilters

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held 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... 287,773 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,513 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans