This post is machine-translated. The original post in german language can be found here.

Override lookup of a field extending RecId

ScreenshotUsing the code example below, I want to show how to override the lookup method of a RecId/RefRecId field. Such a lookup is also referred to as a Referencelookup.

The example serves quite concretely to be able to select a financial dimension, but only one of the type cost center.

public Common lookupReference(FormReferenceControl _formReferenceControl)
{
    SysReferenceTableLookup sysRefTableLookup;
    Query lookupQuery = new Query();
    QueryBuildDataSource lookupQueryDataSource;
                               
    sysRefTableLookup =
        SysReferenceTableLookup::newParameters(
            tableNum(DimensionAttribute), _formReferenceControl);
                      
    sysRefTableLookup.addLookupfield(fieldNum(DimensionAttribute, Name));
                    
    lookupQueryDataSource =
    lookupQuery.addDataSource(tableNum(DimensionAttribute));
               
    lookupQueryDataSource.addRange(
        fieldNum(DimensionAttribute, BackingEntityType)).value(
            queryValue(tableNum(DimAttributeOMCostCenter)));
    lookupQueryDataSource.addRange(
        fieldNum(DimensionAttribute, Type)).value(
            queryValue(DimensionAttributeType::ExistingList));

    sysRefTableLookup.parmQuery(lookupQuery);
               
    return sysRefTableLookup.performFormLookup();
}
These post applies to following version:
Dynamics 365 for Finance and Operations

Add comment
 
 

 

 
 
 
Posts of the actual month
April 2024
MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
2930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.