Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Missing Extension field in the datasource report

(0) ShareShare
ReportReport
Posted on by 275

Hi.

I am having a bit of an issue with extension framework adding a few new fields in the Purchase order report.

I have created an extension of the PurchPurchaseOrderHeader table and added a few new fields:

3404.Capture.PNG

Then I created an event handler class with this method:

    /// <summary>
    ///
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(tableStr(PurchPurchaseOrderHeader), tableMethodStr(PurchPurchaseOrderHeader, initFromPurchTableAllVersions))]
    public static void PurchPurchaseOrderHeader_Post_initFromPurchTableAllVersions(XppPrePostArgs args)
    {
        PurchPurchaseOrderHeader purchPurchaseOrderHeader = args.getThis() as PurchPurchaseOrderHeader;
        PurchTableAllVersions purchTableAllVersions = Args.getArg(identifierStr(_purchTableAllVersions)) as PurchTableAllVersions;
        HcmWorkerEntity hcmWorkerEntity;

        select firstonly hcmWorkerEntity where hcmWorkerEntity.RecId == purchTableAllVersions.WorkerPurchPlacer;

        purchPurchaseOrderHeader.PaymTermId = purchTableAllVersions.Payment;
        purchPurchaseOrderHeader.PurchPlacer = hcmWorkerEntity.Name;
        purchPurchaseOrderHeader.PurchWorkerPhone = hcmWorkerEntity.PrimaryContactPhone;
        purchPurchaseOrderHeader.PurchWorkerEmail = hcmWorkerEntity.PrimaryContactEmail;

    }

Debugging through it seems that my purchPurchaseOrderHeader object is not the extended but the original and I get this in my watch list:

purchPurchaseOrderHeader.PurchWorkerPhone error CS1061: 'PurchPurchaseOrderHeader' does not contain a definition for 'PurchWorkerPhone' and no extension method 'PurchWorkerPhone' accepting a first argument of type 'PurchPurchaseOrderHeader' could be found (are you missing a using directive or an assembly reference?) 

I was of the impression that creating an extension of the table would use that as the object in runtime not the original. What am I doing wrong?

*This post is locked for comments

  • Refshauge Profile Picture
    Refshauge 275 on at
    RE: Missing Extension field in the datasource report

    Just an update. If I look in the file system and navigate to J:\AosService\PackagesLocalDirectory, I understand this is where I find my package. Here I find the model name and in that folder I can see my classes PurchPurchaseOrderControllerExt, PurchPurchaseOrderHeaderHandler as well as my extended table PurchPurchaseOrderHeader.Extension and my report PurchPurchaseOrderExt

    So back to the only class not in "scope" is my DP class. Do I need that in my package and how do I get it in the package when I don't have any changes to add.

    Btw I also have an issue with labels. I created a label file but it doesn't seem to catch that either.

  • Refshauge Profile Picture
    Refshauge 275 on at
    RE: Missing Extension field in the datasource report

    Hi Sukrut.

    Thanks for jumping in. I am nit 100% sure how to check the package if it differs from the model. I created an extension model where I put in all the elements.

    Regards

    Brian Refshauge

  • Refshauge Profile Picture
    Refshauge 275 on at
    RE: Missing Extension field in the datasource report

    Hi Joris.

    Thanks for your reply. I am a bit uncertain whether I get this differentiation on the model vs. the package. I have created a ned model and referenced the Application Suited. Then I created an extension of the table, added fields to it. Then created the a derived controller class as well as a an extended report of PurchPurchaseOrder as described in docs.microsoft.com/.../custom-designs-business-docs.

    As from what I can see all elements should be in my new model and package. The only class could be the DP class which I haven't touched.

    Regards

    Brian Refshauge

  • Suggested answer
    Joris dG Profile Picture
    Joris dG 17,775 on at
    RE: Missing Extension field in the datasource report

    Don't confuse extension with inheritance. When you do an extension, you're extending the original object, not creating a new one. So it's expected that your object is still the old one.

    However, your new fields/methods/etc. should definitely show up. But that's where scoping may come into play. Which package is your extension in, and which package is the event handler in? Not the model, but the package the model is in. This determines the scope. If your extension is in your new model in package 'Brian', then the application suite package is not going to see that extension. So your handlers should go in the same package as the extension.

    You can look at information on C# extension methods, the principles are exactly the same - and packages are assemblies in the context of .NET.

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans