web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

override lookup method on the form inside button clicked mehtod in dynamic dialog

(0) ShareShare
ReportReport
Posted on by 942

Hello,

I have a dynamic dialog created inside clicked() method of the button on the form. Like that:

void clicked()
        {
            Dialog                   dialog;
            DialogField              dlgStatusId;
            EntAssetLifecycleStateId newEOStatusId;
            OGK4_TriCpParameter      paramOrig;
    
            super();
    
            dialog = new Dialog("Копирование");
            
            dlgStatusId = dialog.addField(extendedTypeStr(EntAssetLifecycleStateId));
           
            dlgStatusId.registerOverrideMethod(methodStr(FormStringControl, lookup),methodStr(element, lookupEntAssetLifecycleStateId),this);

How to override lookup method of the dlgStatusID field? Initially I wanted to add new ,lookup method on the form but compiler gives me an error 

pastedimage1628507830573v1.png

So it expects this argument to be a class. I previously overwrote lookup methods in classes inherited from RunBAse classes and such approach worked fine. IN argument I just pointed out the name of my class. But here it's button on the form. So how should I do something like that in this case?

Thanks.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Hi Azat,

    I recommend to use the Runbase approach here, instead of creating the dialog in clicked() method. This way you can also reuse it anywhere in the system - which is not the case if you put the code on the form.

  • dark_knight Profile Picture
    942 on at

    Hi Nicolaos,

    So you mean to write the distinct RunBase class and call it inside button.clicked() method? The thing is that the logic is too simple to write separate class. It just creates a copy of the record but with different status

      [Control("Button")]
        class ParamNormStatCopy
        {
            void clicked()
            {
                Dialog                   dialog;
                DialogField              dlgStatusId;
                EntAssetLifecycleStateId newEOStatusId;
                OGK4_TriCpParameter      paramOrig;
        
                super();
        
                dialog = new Dialog("Копирование");
            
                dlgStatusId = dialog.addField(extendedTypeStr(EntAssetLifecycleStateId));
                
                //dlgStatusId.registerOverrideMethod(methodStr(FormStringControl, lookup),methodStr(element, lookupEntAssetLifecycleStateId),this);
                
                if (dialog.run(false))
                {
                    newEOStatusId = dlgStatusId.value();
                    paramOrig = CPparameter.data();
        
                    CPparameter_ds.allowCreate(true);
                    CPparameter_ds.create();
                    CPparameter.ParamType = OGK4_TriEOParamType::Number;
                    CPparameter.EntAssetLifecycleStateId = newEOStatusId;
                    CPparameter.MinValueNorm = paramOrig.MinValueNorm;
                    CPparameter.MaxValueNorm = paramOrig.MaxValueNorm;
                    CPparameter.MinValueDevice = paramOrig.MinValueDevice;
                    CPparameter.MaxValueDevice = paramOrig.MaxValueDevice;
                    CPparameter.DecDigit       = paramOrig.DecDigit; 
                    CPparameter_ds.allowCreate(false);
                }
            }
    
        }

    So I just need the standard EDT EntAssetLifecycleStateId to show me statuses from the corresponding table. By default it doesn't do that.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I don't think that it's too simple for a separate class. What does that even mean? 

    I think the simplest and nicest solution is to use a separate class. And you already know how to do it, so seems it's the simplest and fastest also from workload perspective.

  • dark_knight Profile Picture
    942 on at

    I mean the logic which is done upon button click is too simple to create a dedicated class for this. That's why I thought I can just somehow add custom lookup right here in clicked() method. Otherwise I'll have to write separate class just for custom lookup creation.

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Well, then we will just agree to disagree, and I hope you can solve your issue your way :)

  • dark_knight Profile Picture
    942 on at

    OK)thanks) maybe you know such approach to create a custom lookup in such a way? right inside clicked() method?

    Thanks.

  • JGjinx321 Profile Picture
    65 on at

    So, is there not a way to do this without creating a separate class? I don't have the same experience as OP in modifying base classes. 

    Currently, I'm trying to get a lookup control added to a string edit field EDT on a dialog form that will appear before running my report.

    The report parameters will be site and that's what I need the lookup to check before running this report. 

    Is there a way to override the newly created dialog field in code in the same class? 

    public static void main(args _args)
    {
        FRSuppItemReportContract contract;
        InventSiteId             SiteId;
        
        Dialog dialogSites = new Dialog("Choose your site");
        DialogField dialogSiteId = dialogSites.addField(extendedTypeStr(InventSiteId))
        
        FRSuppItemReportController controller = new FRSuppItemReportController();
        //controller.parmReportName(ssrsReportStr(FRSuppItemReport, FRSuppItemReport));
        contract  = controller.parmReportContract().parmRdpContract() as FRSuppItemReportContract;
        
        
        
        controller.parmArgs(_args);
    
        controller.parmShowDialog(false);
    
        controller.startOperation();
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans