Skip to main content

How to Override Field Lookup Methods in Dynamics 365 Dialogs

Updated 1 min readMarkdown
Part of seriesDynamics 365 FO Blog
How to Override Field Lookup Methods in Dynamics 365 Dialogs

Bu yazımda Dialog Field’ın lookup’ını nasıl Override edebileceğiniz hakkında bir class paylaşacağım. Bu sayede EDT’nin lookup’ına bağlı kalmadan özel bir lookup oluşturabilir, filtreleme yapabilirsiniz.

class ETGExportDeclarationIdUpdate
{
    CustPackingSlipJour CustPackingSlipJour;
    FRTExportDeclarationId exportDeclarationId;

    public void lookupExportDeclarationId(FormStringControl _formControl)
    {
        Query query = new Query();
        QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(FRTExportDeclarationTable));

        QueryBuildRange qbrCustInvoiceId = queryBuildDataSource.addRange(fieldNum(FRTExportDeclarationTable, CustInvoiceId));
        qbrCustInvoiceId.value(SysQuery::valueEmptyString());

        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(FRTExportDeclarationTable), _formControl, true);

        sysTableLookup.addLookupfield(fieldNum(FRTExportDeclarationTable, ExportDeclarationId));

        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }

    private boolean dialog()
    {
        Dialog dialog = new Dialog("İhracat dosya kodu güncelle");
        DialogField field  = dialog.addField(extendedTypeStr(FRTExportDeclarationId));

        field.registerOverrideMethod(methodStr(FormStringControl, lookup),
            methodStr(ETGExportDeclarationIdUpdate, lookupExportDeclarationId), this);

        if(dialog.run())
        {
            if (!field.value())
                throw warning("İhracat dosya kodu giriniz.");

            exportDeclarationId = field.value();

            return true;
        }

        return false;
    }

    public void run()
    {
        if(this.dialog() && CustPackingSlipJour)
        {
            ttsbegin;
            CustPackingSlipJour.selectForUpdate(true);
            CustPackingSlipJour.ETGExportDeclarationId = exportDeclarationId;
            CustPackingSlipJour.update();
            ttscommit;

            info("İhracat dosya kodu güncellendi.");
        }
    }

    public CustPackingSlipJour parmCustPackingSlipJour(CustPackingSlipJour _CustPackingSlipJour = CustPackingSlipJour)
    {
        CustPackingSlipJour = _CustPackingSlipJour;

        return CustPackingSlipJour;
    }

    public static void main(Args args)
    {
        if (! args || ! args.dataset() || ! args.record() ||
            args.record().TableId != tablenum(CustPackingSlipJour) )
        {
            throw error(Error::missingRecord(funcname()));
        }

        ETGExportDeclarationIdUpdate etgExportDeclarationIdUpdate = new ETGExportDeclarationIdUpdate();
        etgExportDeclarationIdUpdate.parmCustPackingSlipJour(args.record());
        etgExportDeclarationIdUpdate.run();
    }

}

About the author

No comments yet. Be the first to comment.

Dynamics 365 FO Blog

Part 27 of 33

Microsoft Dynamics 365 for Finance and Operations ürünü ile ilgili yaptığım işler ve tecrübelerim

Up nextDynamics 365 Find Exchange RateDöviz Kuru Bulmak