Thursday, 9 January 2025

Lookup method in d365 FO

 [ExtensionOf(formStr(PurchCreateOrder))]

final class _PurchCreateOrder_F_Extension

{

    void init()

    {

        next init();

        PurchTable_Coentre.registerOverrideMethod(methodStr(FormDataObject, lookup), formMethodStr(PurchCreateOrder, overrideCoentreLookup));

    }


    public void overrideCoentreLookup(FormStringControl _formControl)

    {

        Query query = new Query();

        QueryBuildDataSource qBDSInventCoentre;

        QueryBuildDataSource qBDSUserCoentreMaintain;


        SysTableLookup  sysTableLookup  = SysTableLookup::newParameters(tableNum(DimAttributeOMCoenter), _formControl);


        sysTableLookup.addLookupfield(fieldNum(DimAttributeOMCoenter, value));

        sysTableLookup.addLookupfield(fieldNum(DimAttributeOMCoenter, Name));


        qBDSInventCoentre = query.addDataSource(tableNum(DimAttributeOMCoenter));


        if (_UserCoentreMaintain::checkUserExists(curUserId(), curExt()))

        {

            qBDSUserCoentreMaintain = qBDSInventCoentre.addDataSource(tableNum(UserCoentreMaintain));

            qBDSUserCoentreMaintain.joinMode(JoinMode::InnerJoin);

            qBDSUserCoentreMaintain.relations(false);

            qBDSUserCoentreMaintain.addLink(fieldNum(DimAttributeOMCoenter, value),  fieldNum(UserCoentreMaintain, coentre));

            qBDSUserCoentreMaintain.addRange(fieldNum(_UserCoentreMaintain, UserId)).value(queryValue(curUserId()));

            qBDSUserCoentreMaintain.addRange(fieldNum(_UserCoentreMaintain, LegalEntity)).value(curExt());

        }

        sysTableLookup.parmQuery(query);

        sysTableLookup.performFormLookup();

    }

}


No comments:

Post a Comment

DefaultDimension in d365 FO X++

 Navigate to PurchTable methods you can find with DefaultDimension this.DefaultDimension = this.mergeDimension(this.getDefaultDimension(),th...