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 :
Finance | Project Operations, Human Resources, ...
Answered

Create parameter table for custom module

(0) ShareShare
ReportReport
Posted on by 230

Hi team,

 

I need to create a parameter table for a custom module in D365FO. 

 

Could you please guide me through the necessary steps and best practices that I should follow while creating it? So, that it will allow to create only one record.

 

Pls advise, thanks 

Categories:
  • Suggested answer
    Martin Dráb Profile Picture
    241,635 Most Valuable Professional on at
  • CU29091230-0 Profile Picture
    230 on at

    Hi Martin, thanks for the response.

     

     

    What I understood 

     

    The Key field is normally used to ensure that only one parameter record can exist in the table.

     

    1. My question is here, what fields are contained in Key field?

     

     

    Table parameter - find method 

     

    client server static MyModuleParameters find()
    {
       MyModuleParameters parameter;
       ;
       select firstOnly parameter
           index Key
           where parameter.key == 0;

       if (!parameter)
       {
           Company::createParameter(parameter);
           NumberSeqReference::construct(MyParameters::numberSeqModule()).load();
       }
       return parameter;
    }

     

    2. As per the above code, if parameter does not exist then initiate it and create it.  Is it?

     

    Form paraneter- 

    Do not set the TitleDatasource property in the design properties. There is only one record and no identifying key.

     

    3. In the Form parameter , design property, Why not to set.Title datasource?

     

    Pls advise thanks 

  • Verified answer
    CU-1234529-002 Profile Picture
    631 on at

    Hi,

    1. The Key field isn't multiple fields, it's a single integer field, usually based on a tiny enum with one value, always set to 0. A unique index on it ensures only one row can ever exist, since every record must have Key equal to 0.

    2. Yes, correct. If no parameter record exists yet, find creates one automatically and also initializes the number sequence, so calling code always gets a valid record.

    3. TitleDatasource is meant to show something that identifies a specific record, like a customer account number. Since a parameter table only ever has one record, and its key field is just a meaningless constant zero, there's nothing useful to show as a dynamic title, so it's left unset.

    And yes, that's exactly the purpose of a parameter table. Any fixed or setup values for your module, default accounts, toggles, number sequences, integration URLs, thresholds, and so on, belong here instead of being hardcoded in X++, so they can be changed later through a setup form instead of a code change.

    Thanks 

  • CU29091230-0 Profile Picture
    230 on at

    Thanks for the response.

     

    Could you please confirm whether the Key field is what ensures that only one record can exist in a Parameter table in D365FO?

     

    As mentioned ‘since every record must have Key equal to 0.’

     

    Could you please explain with example. Sorry not understand.

     

    Pls advise, thanks 

     

     

  • Verified answer
    CU-1234529-002 Profile Picture
    631 on at

    Yes, the Key field is always 0 because it is an integer field, and the default value of an integer in D365FO is 0. The field is system-controlled/greyed out, so the user cannot manually change it.

    Since the CustParameters table is designed to have only one parameter record per legal entity, the first record is created with key = 0. If we try to create a second record, it will also have key = 0, causing a duplicate-key error, as shown in the attached screenshot.

    So, the custParameters record is legal-entity specific, with one parameter record per legal entity.

    If you attempt to create second record shows below error

    Thanks!

  • Verified answer
    Martin Dráb Profile Picture
    241,635 Most Valuable Professional on at
    The uniqueness is guaranteed by the index, not the field (remember the step “Create a unique index called keyIdx, that consists of the field key”).
  • CU29091230-0 Profile Picture
    230 on at

    Hi team,

     

    Sorry, db restore process is going on that's why unable to access of the system.

     

    Meanwhile , I have one query 

     

    As mentioned “The field is system-controlled/greyed out, so the user cannot manually change it.”

     

    For my custom parameter table, do I need to create the Key field manually, or is it generated automatically based on certain configurations or properties?

     

    Pls advise, thanks 

     

  • Martin Dráb Profile Picture
    241,635 Most Valuable Professional on at

    Are you sure that you don't want to simply read the documentation page? Your questions are already there. For instance, it says:

    Add an integer field that is named key. It should have the Visible property set to No, and the Mandatory property set to No (because it holds the value 0).

    This makes clear that it's a field you need to add. It's just a normal field as any other; it's not something managed by the system. CU-1234529-002 probably meant that the field isn't editable by users.

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

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 232 Most Valuable Professional

#3
Aayush Tiwari Profile Picture

Aayush Tiwari 222

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans