AxdBase.initQueryFromEntityKey Method [AX 2012]

Instantiates the query associated with the Axd document and stores it in a variable on the AxdBase class.

Syntax

public void initQueryFromEntityKey([AifEntityKey _aifEntityKey, boolean _validateEntityKey])

Run On

Server

Parameters

  • _aifEntityKey
    Type: AifEntityKey Class
    An entity key that contains the key data element. Used to add ranges to the query. The default is nullNothingnullptrunita null reference (Nothing in Visual Basic).
    If the method is called by using an entity key as a parameter, the key data part of the entity key is used to add ranges to the query.
  • _validateEntityKey
    Type: boolean
    A Boolean that specifies whether the entity key should be validated. The default is false.

Remarks

The initQueryFromEntityKey method is called from the AxdBase class. The method can be overridden to provide document-specific query initialization, such as the disabling of data sources or populating the query with specific values for ranges. The implementation on the AxdBase class instantiates the query associated with the document class.

The method is called for both read and create operations, but an entity key is provided only for read operations.

Examples

The following example shows how initQueryFromEntityKey is overridden on the AxdPurchaseRequisition Class.

public void initQueryFromEntityKey( 
    AifEntityKey _aifEntityKey = null, 
    boolean _validateEntityKey = false) 
{ 
    VendPurchOrderJour      vendPurchOrderJour; 
    if(_aifEntityKey) 
    { 
        if (_aifEntityKey.parmTableId()==tablenum(VendPurchOrderJour)) 
        { 
            vendPurchOrderJour = SysDictTable::findFromKeyData( 
                _aifEntityKey.parmTableId(), 
                _aifEntityKey.parmKeyDataMap().pack()); 
            if (vendPurchOrderJour) 
            { 
                if (PurchTable::find( 
                  vendPurchOrderJour.PurchId).PurchStatus != 
                  PurchStatus::Backorder) 
                { 
                    throw error(strfmt( 
                        "@SYS89370", 
                        vendPurchOrderJour.PurchId)); 
                } 
            } 
        } 
    } 
    super(_aifEntityKey, _validateEntityKey); 
    this.disableDataSources(); 
}

See Also

AxdBase Class

AxdBase.initQueryFromQuery Method