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
September 2021
MoTuWeThFrSaSu
 12345
6789101112
13141516171819
20212223242526
27282930 
 
© 2006-2021 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.