Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

The display method on the data source in AX 2012 cannot obtain complete data

Posted on by 103

I tried adding this method to the InventSum data source table to obtain the InventBatch table, but the Display method failed to obtain the InventDimId value.

I can only get the value of itemId and not the value of InventDimId. Why?What should I do?

pastedimage1603262692223v1.png

display  ExpirationDate ExpDate(InventSum _inventSum)
{
    ItemId          d_itemId        = inventSum.ItemId;
    InventDimId     d_InventDimId   = inventSum.InventDimId;

    InventBatchId d_batch = InventDim::find(d_InventDimId).inventBatchId;
    ExpirationDate l_date = InventBatch::find(d_batch,d_itemId).expDate;

    return l_date;
}

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,417 on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    Since this is a custom form based on On hand inventory form, could you please share the query being used for the data source?

  • Danzel Zuo Profile Picture
    Danzel Zuo 103 on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    Try your code and still cannot get the InventDimId value, you post the same code as mine,thanks again

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,417 on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    In line 4 of the, you are using the variable d_InventDimId. But you are not using the active buffer that is passed into the display method.

    Please try this code and check if you are getting the InventDimId value

    display  ExpirationDate ExpDate(InventSum _inventSum)
    {
        ItemId          d_itemId        = _inventSum.ItemId;
        InventDimId     d_InventDimId   = _inventSum.InventDimId;
    
        InventBatchId d_batch = InventDim::find(d_InventDimId).inventBatchId;
        ExpirationDate l_date = InventBatch::find(d_batch,d_itemId).expDate;
    
        return l_date;
    }

  • Danzel Zuo Profile Picture
    Danzel Zuo 103 on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    Thank you for your reply. I wrote it in line 4 of the code

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,417 on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    You are passing the table buffer (_inventSum) to the display method and are not using it. Can you try this and check if you get any value for InventDimId?

    InventDimId     d_InventDimId   = _inventSum.InventDimId;

  • Danzel Zuo Profile Picture
    Danzel Zuo 103 on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    Thank you for your reply,This is a Form of personalized development, similar to the summary of on-hand Inventory(Show the inventory quantity  of all Items)

    Path:Product information management/Common/Released products->Manage inventory->on-hand Inventory

  • Martin Dráb Profile Picture
    Martin Dráb 225,526 Super User on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    It's not completely empty - it has ItemId and quantities. That's why I assume it's actually grouped. It explains the empty RecId as well - as with other fields, the value of RecId isn't defined if it's neither grouped by nor aggregated.

  • István Orosz Profile Picture
    István Orosz 2,137 on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    Hi Danzel,

    InventSum record buffer is empty - you should first fix the query behind.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,526 Super User on at
    RE: The display method on the data source in AX 2012 cannot obtain complete data

    The problem isn't in the code above - the problem is in what query the form uses. It seems it uses grouping and the fields that are neither grouped by not aggregated simply don't have any value fetched from the database.

    If you're interested in details, look at the form in question. If you don't understand what's going on and you need help, tell us which form it is.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,835 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,526 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans