Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / BPUpgradeCodeLateBound...
Finance forum
Unanswered

BPUpgradeCodeLateBoundCall

(1) ShareShare
ReportReport
Posted on by
Hi,

I got this BP warning:

BP Rule: [BPUpgradeCodeLateBoundCall]:A late bound call type.Id 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.  

Here's the code for a table method

    public static List getAllXX(AccountNum _accountNum, NoYesId _extra = NoYes::No)
    {
        Table1        table1;
        Table2        table2;
        Table3        table3;
        Table4        table4;

        Object        type;
        
        List r = new List(Types::Class);

        while select table1 where table1.AccountNum ==_accountNum
            join table2 ...etc
        {

            if(table1)
            {
                if(_extra)
                {
                    type = new classContractXExtra();
                    type.DOverride(table4.DOverride);
                }
                else
                {
                    type = new classContractX();
                }
                type.Id(table3.Id);
                type.Id2(table2.Ids);
                type.TypeId(table3.DType);

                r.addEnd(type);
            }
        }

        return r;
    }


i got the error for type.Id, type.Id2, type.TypeId and type.DOverride

can someone explain the error? why i'm getting it? and what do i need to do exactly?
  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    BPUpgradeCodeLateBoundCall
    Yes, that's the correct approach.
     
    If you declare the variable as Object, you lose all compile-type control. You can call a method that doesn't exist and your code will compile, but it'll fail on runtime. And even if you the method exists, the call will be much slower than if the right type is know to the compiler. Therefore it's a bad thing in both cases.
  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    BPUpgradeCodeLateBoundCall
    If classContractXExtra is a child of classContractX, then use classContractX in the variable declaration.
      
    If they're completely independent classes, then your solution isn't designed correctly.
  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    BPUpgradeCodeLateBoundCall
    You've used a wrong type when declaring your variable called type. The type should be classContractXExtra, not Object.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans