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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

virtual field not getting detected in post load method

(0) ShareShare
ReportReport
Posted on by 1,836

I was trying to add the virtual field in data entity by using that virtual field i am trying  physical quantity of item by site and warehouse but my postload method is showing errors what should i have to do to make it work 

 i have added the field in staging table 

now i had made the class which will get the values ,plz can any one guide me on this how can i get this done.

[ExtensionOf(viewstr(QuantityEntity))]
final class QuantityEntity_Extension
{
    
    public void  postload()
    {
        inventOnHand    inventcls;
        InventQty       inventQty;

        this.InventSiteId = inventDim::find(this.InventSiteId).InventSiteId;
        this.InventLocationId = inventDim::find(this.InventLocationId).InventLocationId;
           
        inventcls = inventOnHand::newItemId(this.ItemId);

        inventQty = inventcls.physicalInvent();
        return inventQty;
   
        next postload();

    }
}
 

  • Suggested answer
    GirishS Profile Picture
    27,843 Moderator on at

    Hi Dinesh,

    Please refer to the below blog for creating virtual field and assigning fields. Error is due to the return type you are using. PostLoad method doesn't have any return type.

    Please refer to any one of the below blog and implement it.

    https://usdynamics365.wordpress.com/2020/04/12/data-entity-create-virtual-field-microsoft-dynamics-365-for-finance-and-operations/

    https://codingchamp.blogspot.com/2018/04/virtual-fields-in-data-entity-in.html

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,573 Moderator on at

    Hi Dinesh, Please remove Line# 16 which is return inventQty. Instead you can try  this.InventQty = inventcls.physicalInvent();

    I am assuming InventQty is name of Virtual field. Also, better to call next postLoad() first, then your custom code.

  • Dineshkarlekar Profile Picture
    1,836 on at

      hi

    girishs,

    MOHIT,

    Thanks for the link 

    i had made the changes in code 

    OnHandQuantityVS is the vertual field where i have to get data and invent on hand is the method which calculate the data.

    do i have to make any changes .plz suggest

     public void postLoad()
        {
            InventOnhand                     inventOnHand;
          
            super();
    
            inventOnHand = inventOnHand::newItemId(this.ItemId);
            this.InventSiteId     = inventDim::find(this.ItemId).InventSiteId;
            this.InventLocationId = inventDim::find(this.ItemId).InventLocationId;
    
            this.OnHandQuantityVS = inventOnHand.availPhysical();  
        }

    thanks 

    regards

    dinesh

  • GirishS Profile Picture
    27,843 Moderator on at

    Seems this is fine. Please test and let us know the output.

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

    You don't need to find InventDim table buffer twice. And there can be multiple records in InventDim for an ItemId with different InventSiteId and inventLocationId, so how will you find the correct or required site and warehouse?

  • André Arnaud de Calavon Profile Picture
    307,143 Super User 2026 Season 2 on at

    The InventDim table is not having a field for the ItemId. You would need to have a InventDimId to find a specific record in this table. With your current coding, you will not get an InventSiteId or InventLocationId.

    What is the exact requirement for this data entity? Do you need one line for each item or do you have inventory for the same item on multple sites and warehouses?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 426 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 358

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 353 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans