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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to add display method to the form datasource?

(0) ShareShare
ReportReport
Posted on by 843

Hello,

I'm trying add additional display method to InventSum datasource on InventOnhandItem form.

I attached my code below. I'm have debbuged this and always _inventSum equals "No data selected".

Can anyone suggest how it should be done correctly?

Thanks.

[ExtensionOf(formDataSourceStr(InventOnhandItem, InventSum))]
final class InventOnhandItem_XXX_Extension
{
    display Qty MyDisplay(InventSum _inventSum)
    {
        InventSum inventSum;
        FormDataSource InventSum_ds = _inventSum.datasource();
        FormDataSource InventDim_ds  = InventSum_ds.formRun().dataSource("InventDim");

        return InventSum.MyMethod(_inventSum, InventDim_ds);
    }
}

I have the same question (0)
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Instead of inventsum.datasource, give this.cursor();

    I am not sure you can create a display method in form datasource. Ideally I will create that in table level and add that to a form as a new field.

  • Shooowtek Profile Picture
    843 on at

    How on the InventSum table will I be able to get inventDim_ds?

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

    Hi, You can get InventDim table buffer using below code, provided InventSum_ds is not empty.

    InventDim inventDim = InventDim_ds.cursor();

  • Shooowtek Profile Picture
    843 on at

    I have a display method created on the InventSum datasoure of the InventOnhandItem form. Based on the debugging I did on this method, _inventSum is "No data selected"

    This method calls the myMethod from the InventSum table extension.

    [ExtensionOf(formDataSourceStr(InventOnhandItem, InventSum))]
    final class InventOnhandItem_InventSum_XXX_Extension
    {
        display Qty myDisplay(InventSum _inventSum)
        {
            FormDataSource inventSum_ds = _inventSum.datasource();
            InventSum inventSum = inventSum_ds.cursor();
            FormDataSource inventDim_ds = inventSum_ds.formRun().dataSource("InventDim");
    
            return InventSum.MyMethod(_inventSum, InventDim_ds);
        }
    
    }

    [ExtensionOf(tableStr(InventSum))]
    final class InventSum_XXX_Extension
    {
        public Qty myMethod(InventSum _inventSum, FormDataSource _ds)
        {
            InventTrans inventTrans;
            InventDim inventDim;
    
            Common common = formJoinedRecord(_inventSum, _ds);
    
            if(common.TableId == tableNum(InventDim))
            {
                inventDim = common as InventDim;
            }
    
            if(inventDim.InventLocationId)
            {
                return 99;
            }
    
            return 0;
        }
    
    }

    The requirement is that the display is to show a value of 99 if the 'Location' storage dimension is enabled and not empty for the row.
    I have the same logic in AX12 and there it works without any problem. I'm trying to get it into D365, but with no results.

    Could you please help me?

  • Shooowtek Profile Picture
    843 on at

    Does anyone have any suggestions?

  • Shooowtek Profile Picture
    843 on at

    Could someone please help?

  • Suggested answer
    Muhammad Saad Salman Profile Picture
    29 on at

    Hi,

    [ExtensionOf(formDataSourceStr(InventOnhandItem, InventSum))]
    final class InventOnhandItem_InventSum_XXX_Extension
    {
        display Qty myDisplay(InventSum _inventSum)
        {
            FormDataSource inventDim_ds = this.formRun().dataSource("InventDim");
    
            return _inventSum.MyMethod(inventDim_ds);
        }
    
    }

    [ExtensionOf(tableStr(InventSum))]
    final class InventSum_XXX_Extension
    {
        public Qty myMethod(FormDataSource _ds)
        {
            InventDim inventDim;
    
            inventDim = _ds.cursor();
            
            if(inventDim.InventLocationId)
            {
                return 99;
            }
    
            return 0;
        }
    
    }

    Please try the above logic and check if it works.

  • Shooowtek Profile Picture
    843 on at

    Thank you, but unfortunately it doesn't work

  • Shooowtek Profile Picture
    843 on at

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 659 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 533 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 289 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans