Skip to main content

Notifications

Finance forum
Suggested answer

Parameters table

Posted on by 132
Hi

In each find method in parameters table, there is these three lines of code circled in grey


1. What do those three lines do? and why do we need them?

2. I noticed that the line highlighted in yellow might vary from parameter table to another
so it could be this:
PriceDiscPurchPolicyParameters::initParameters();
OR it could be 2 lines
PrintMgmt::createDefaultData(PrintMgmtHierarchyType::Project);
ProjStatusTypeRule::createDefaultData();
OR it could be three lines
 PurchSummaryParameters::initiateAll();
 PrintMgmt::createDefaultData(PrintMgmtHierarchyType::Purch);
 PurchTable2LineParameters::initiate();

what are those?

3. If i created a new module what shall i call after company::createParameter()?
  • Andre Arnaud de Calavon Profile Picture
    Andre Arnaud de Cal... 283,405 Super User on at
    Parameters table
    Hi,
     
    1) As mentioned, you can indeed skip the number groups. In the standard application, you can set up e.g. invoice numbers per group. You can then set up a number sequence group on the customer details that drives what number series to use. If you don't need a similar feature, you can ignore the menu item buttons for the number groups.  
     
    2) I think the coding is used for having specific lookups and filter the number sequences with specific settings. For the standard bank fieds you mentioned, the best practice is having continuous number sequences. The lookup list with number sequences will then be restricted to choose from continuous number sequences only. Also here, if you don't need similar logic, you can skip the coding related to the switch-statement.
  • CU04051814-0 Profile Picture
    CU04051814-0 132 on at
    Parameters table
    Hi Andre,

    1. I looked at BankParameters, it seems it has only one menu item about grouping, which i don't understand what it does, do u know what it does? but i think u are suggesting that I don't put any menu items in my new setup form, right?





    2. I'm also trying to copy the code in bank parameters a su suggested, what should i replace this code below with? what does this code do? and what shall i replace BankLGNumber and BankLGTransNumber with?
        [DataField]
        class NumberSequenceId 
        {
            public Common resolveReference(FormReferenceControl _formReferenceControl)
            {
                NumberSequenceCode code = _formReferenceControl.filterValue(
                    AbsoluteFieldBinding::construct(fieldStr(NumberSequenceTable, NumberSequence),
                    tableStr(NumberSequenceTable))).value();
    
                // Do not call super as we're providing our own disambiguation logic.
                // resolvedRecord = super(_formReferenceControl);
    
                return NumberSequenceTable::findByNaturalKey(code, scope.getId(true));
            }
    
            public Common lookupReference(FormReferenceControl _formReferenceControl)
            {
                SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(NumberSequenceTable), _formReferenceControl, true);
    
                // Do not call super as we're providing our own custom lookup logic.
                // selectedRecord = super(_formReferenceControl);
    
                // Display the Title and Department fields in the lookup form.
                sysTableLookup.addLookupfield(fieldNum(NumberSequenceTable, NumberSequence));
    
                // Create a custom Query that filters on NumberSequenceScope.
                Query lookupQuery = new Query();
                lookupQuery.addDataSource(tableNum(NumberSequenceTable)).addRange(fieldNum(NumberSequenceTable, NumberSequenceScope)).value(queryValue(scope.getId(true)));
                sysTableLookup.parmQuery(lookupQuery);
    
                switch (NumberSequenceDatatype::find(numberSequenceReference.NumberSequenceDatatype, false).DatatypeId)
                {
                    case extendedTypeNum(BankLGNumber):
                    case extendedTypeNum(BankLGTransNumber):
                        lookupQuery.dataSourceTable(tableNum(NumberSequenceTable)).addRange(fieldNum(NumberSequenceTable, Continuous)).value(queryValue(NoYes::Yes));
                        break;
                }
    
                // Return the record selected by the user.
                NumberSequenceTable selectedRecord = sysTableLookup.performFormLookup();
    
                return selectedRecord;
            }
    
        }
    
    }
     
     
  • Andre Arnaud de Calavon Profile Picture
    Andre Arnaud de Cal... 283,405 Super User on at
    Parameters table
    Hi,
     
    I usually take a smaller module as an example where it uses the minimum required objects for creating a new parameters form for a new module. You can have a look at the BankParameters. You will then find out that there is less coding and fewer objects available.
     
    1. The Parameters form will usually have a parameters table as a data source where it is not allowing to create new records. For that reason, the required single parameter record will be created using this X++ code.
     
    2. Have a look at the example BankParameters as mentioned before. 
     
    3. Also here, you can have a look at the BankParameters. I don't know if your solution should support groups for the number sequences. In the past, I never used the action buttons on the number sequences tab.
  • CU04051814-0 Profile Picture
    CU04051814-0 132 on at
    Parameters table
    Hi Andre,

    1. So if I don't put the "createParameter" in my new module, an error will appear?
     
    2. Do other modules put this additional initialization because an error will be thrown if they don't put it? and why they don't initialize it in their specific form instead of parameters?
     
    3. If I want to add a number sequence tab in my newly created parameter form, shall i copy everything done in other modules?
    For example, in CustParameters, there are three menu items about the number sequence above the grid, and there is code to make them visible based on conditions
     -- do i need those menu items?
  • Suggested answer
    Andre Arnaud de Calavon Profile Picture
    Andre Arnaud de Cal... 283,405 Super User on at
    Parameters table
    Hi,
     
    This is a great question. Let me try to help you.
     
    1. For every parameter table, there should be one record per legal entity. The code in this method will ensure a record does exists in case the form is opened the first time.
     
    2. Depending on the module and settings required, it will create additional default records, depending on the functionality.
     
    3. In case you created a module yourself, it is not required to call logic after calling the Company::createParameter() method. This would only be required if you need more initialization of some default setup data required by your module.

Helpful resources

Quick Links

Upcoming TechTalk: Copilot Capabilities…

Review the Copilot features that are currently available in Dynamics 365 Finance…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,405 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,370 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans