Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Getting BR warning "BPUpgradeCodeLateBoundCall" by calling custom method in Form Method in D365 FO

(0) ShareShare
ReportReport
Posted on by

Hi,

1. I am customizing XYZ Form. I want to initialize few fields based on newly created custom field.

2. I want to call my custom form method 'myUpdateDesign()' which I have created in Extension class of XYZ form to update design. I created the event handler of 'onModified()' method. I have initialized the FormRun object and trying to call form methods. 

[SuppressBPWarning('BPParameterNotUsed', 'Parameter e required in signature'),
    FormDataFieldEventHandler(formDataFieldStr(XYZ, myDb, myField), FormDataFieldEventType::Modified)]
    public static void myField_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        FormDataObject                     caller          = sender as FormDataObject;
        FormRun                            formRun         = caller.dataSource().formRun();
        FormDataSource                     myDB_ds = caller.dataSource().formRun().dataSource(formDataSourceStr(XYZ,myDB));
        AVAProjGrant                       myDB    = myDB_ds.cursor();

        if(myDB.myField == NoYes::Yes)
        {
             formRun.myUpdateDesign(false);
        }	

}

3. It is working but I'm getting below mention BPRule error 

BP Rule: [BPUpgradeCodeLateBoundCall:A late bound call formRun.avaUpdateDesignExRateTab is made. In source system (AX 2012) it is possible to dynamically call methods where the number and type of the parameters does not match with the method definition. This is not supported in AX 7, where the number and types of parameters have to match. Even if the parameters do match, the late bound call is extremely expensive. Mitigation: Use a class or interface hierarchy to provide a type safe fast call, or use the IS and AS operators to cast to a known type before calling.

Can you please help me how can I use my custom form methods without BP warning?

Thanks in advance!

Regards,

Aimon Fatima

  • Community Member Profile Picture
    on at
    RE: Getting BR warning "BPUpgradeCodeLateBoundCall" by calling custom method in Form Method in D365 FO

    Thank you  Blue Wang and Sergei Minozhenko for the solution..

    Yes. It's standard form.

    I'll suppress the warning.

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,091 on at
    RE: Getting BR warning "BPUpgradeCodeLateBoundCall" by calling custom method in Form Method in D365 FO

    Hi Aimon,

    If it's a standard form, you can only suppress the warning.

    For your own forms, you can create an interface with myUpdateDesign method. In the modified method you will need to cast formRun object to interface and execute method from the interface.

    [SuppressBPWarning('BPParameterNotUsed', 'Parameter e required in signature'),
        FormDataFieldEventHandler(formDataFieldStr(XYZ, myDb, myField), FormDataFieldEventType::Modified)]
        public static void myField_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
        {
            FormDataObject                     caller          = sender as FormDataObject;
            FormRun                            formRun         = caller.dataSource().formRun();
            IMyUpdateDesign                    iMyUpdateDesign = formRun as IMyUpdateDesign; //Cast to interface
            FormDataSource                     myDB_ds = caller.dataSource().formRun().dataSource(formDataSourceStr(XYZ,myDB));
            AVAProjGrant                       myDB    = myDB_ds.cursor();
    
            if(myDB.myField == NoYes::Yes && iMyUpdateDesign != null)
            {
                 iMyUpdateDesign.myUpdateDesign(false);
            }	
    
    }

  • Verified answer
    Blue Wang Profile Picture
    on at
    RE: Getting BR warning "BPUpgradeCodeLateBoundCall" by calling custom method in Form Method in D365 FO

    HI Aimon Fatima,

    You can find related BP suppression file at \AosService\PackagesLocalDirectory\<ModelName>\<ModelName>\AxIgnoreDiagnosticList.

    Then add:

    BestPractices
    Warning
    dynamics:// //You can get this path from warning message
    BPParameterNotUsed 
    FormDataSourceEventArgs e is mandatory parameter for events and not used in the current context.
    

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,011 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans