Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / The next method cannot...
Finance forum

The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

(0) ShareShare
ReportReport
Posted on by 455

Trying to extend initValue method on CustCustomerV3Entity. The goal is to auto-generate customer account number when customer record is inserted via the data entity.

I'm not clear why CoC isn't working. Even though CustCustomerV3Entity doesn't implement this method, it still inherits it from Common. This should work according to

docs.microsoft.com/.../method-wrapping-coc

What are my options? The only other option I can think about is creating my own data entity but this seems to be a huge overkill.

Here's the code I'm trying to use

[ExtensionOf(tableStr(CustCustomerV3Entity))]
final class CustCustomerV3Entity_Extension
{
    public void initValue()
    {
        next initValue();

        if (!this.skipNumberSequenceCheck())
        {
            NumberSeqRecordFieldHandler::enableNumberSequenceControlForField(
                this, fieldNum(CustCustomerV3Entity, CustomerAccount), CustParameters::numRefCustAccount());
        }
    }

}


  • Alex Kaganov Profile Picture
    455 on at
    RE: The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

    Forgot to update you guys - this was turned out a bug in PU21 that Microsoft acknowledged and fixed in PU22.

  • Mea_ Profile Picture
    60,278 on at
    RE: The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

    Unfortunately I don't know the answer, so you have to try all of them ( events) to see if there is suitable one. If you wouldn't find any you have 2 options:

    easy one, to duplicate entity and add code wherever you need or open extensibility request to ask MS to make it extensible. But it could be rejected just because you have easy work around - duplicate entity or because there is a deal for extensibility requests...

  • Alex Kaganov Profile Picture
    455 on at
    RE: The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

    Ievgen, I see what you mean now.

    Question here - is this something Microsoft aware of and will be fixing in the upcoming releases? According to the wiki, it should be possible to CoC methods that are not overriden in a specific class. I don't see why this should not be working on data entities.

    In regards to this particular case, unfortunately I don't think your solution will work. The NumberSeqRecordFieldHandler must be initialized in the initValue before the call into the base method. This is because enableNumberSequenceControlForField method establishes certain event subscriptions, most importantly a subscription to onInitializingRecord. If I call NumberSeqRecordFieldHandler::enableNumberSequenceControlForField inside the onInitializingRecord, it will subscribe but will never be called. If I had another event that fires before onInitializingRecord, I could try that but I think onInitializingRecord is the first available event in the sequence of data entity execution.

  • Suggested answer
    Mea_ Profile Picture
    60,278 on at
    RE: The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

    I was actually talking about events you have, like InitializingEntityDataSource or InitializingRecord, try one of them. Your way with extension works only if entity has this method but unfortunately it is not defined for CustCustomerV3Entity

  • Alex Kaganov Profile Picture
    455 on at
    RE: The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

    Thanks ievgen!

    I'm on PU21. Is there anything specifically that I need to enable? I have just rebuilt all models but that did not make any difference.

    As for event handlers, I thought about it but I don't believe I can use them. initValue() is not overriden by the CustCustomerV3Entity so I don't think I can attach an event handler.

  • Alex Kaganov Profile Picture
    455 on at
    RE: The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

    Hi Venkatesh,

    Thank you for your response!

    I'm on PU21. I compared the syntax of your sample against what I have and it's the same with the exception of tablestr() vs dataentityviewstr(). I tried this but it didn't make any difference. The compiler is still complaining about me using the next() call,

  • Mea_ Profile Picture
    60,278 on at
    RE: The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

    To get CoC on data entities you need to install PU mentioned above, but you can always use event handlers to achieve the same if CoC does not work for you.

  • Community Member Profile Picture
    on at
    RE: The next method cannot be invoked in method 'initValue' because it's not a Chain Of Command Method

    Hi Alex,

    Enable Chain of Command for data entities from Platform update 20 and the syntax follows.

    docs.microsoft.com/.../platform-extensibility

    [ExtensionOf(dataentityviewstr(CustCustomerV3Entity))]

    final class CustCustomerV3Entity_Extension

    {

       public void initValue()

       {

       }

    }

    Thanks,

    Venkatesh

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... 293,202 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans