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 :
Microsoft Dynamics AX (Archived)

how to bound display method to the form values

(0) ShareShare
ReportReport
Posted on by 1,092

Hello,

I need on the form RouteInventProd to add a display method to the "Overview" tab of the lower grid that will take values from the tab "Resource Requirements" and depending on the value display different values.

I write something like this:

display ProdUnitId prodUnitId1()
{
    RouteOpr                        routeOpr1;
    WrkCtrRouteOprActivity          wrkCtrRouteOprActivity;
    WrkCtrActivityRequirementSet    wrkCtrActivityRequitementSet;
    WrkCtrActivityRequirement       wrkCtrActivityRequirement;
    WrkCtrResourceGroup             wrkCtrResourceGroup;
    WrkCtrResourceGroupResource     wrkCtrResourceGroupResource;

select * from wrkCtrActivityRequirement
        join wrkCtrActivityRequitementSet
            where wrkCtrActivityRequitementSet.RecId == wrkCtrActivityRequirement.ActivityRequirementSet
        join wrkCtrRouteOprActivity
            where wrkCtrRouteOprActivity.Activity == wrkCtrActivityRequitementSet.Activity
        join routeOpr1
            where routeOpr1.RecId == wrkCtrRouteOprActivity.RouteOpr;              
    
    
if (wrkCtrActivityRequirement.RelationshipType == WrkCtrActivityRequirementType::ResourceGroup)
    {
        select * from wrkCtrResourceGroup
            where wrkCtrResourceGroup.WrkCtrId == wrkCtrActivityRequirement.requirementEdit();
        return wrkCtrResourceGroup.ProdUnitId;
    }
    
else if (wrkCtrActivityRequirement.RelationshipType == WrkCtrActivityRequirementType::Resource)
    {
        select * from wrkCtrResourceGroupResource
            where wrkCtrResourceGroupResource.WrkCtrId == wrkCtrActivityRequirement.requirementEdit();
        select * from wrkCtrResourceGroup
            where wrkCtrResourceGroup.RecId == wrkCtrResourceGroupResource.ResourceGroup;
        return wrkCtrResourceGroup.ProdUnitId;
    }
    
    return " ";
            
}

I add this display method to the table "RouteOpr" and then add this table as data source to the form. Then as JoinSource I point out "ProdRoute" table and type is OuterJoin.
But my query from above always returns the same value and doesn't bound anyhow to the values on the form. Tell me please how can I bound to the form values? It's Tab "Resource Requirements"

115.JPG

The values I need:

2480.114.JPG

In case of additional questions please feel free to ask. Thanks you.

*This post is locked for comments

I have the same question (0)
  • nmaenpaa Profile Picture
    101,166 Moderator on at

    Is any condition in the select statement in your display method tied to your form data source in any way? To me it looks you are declaring local table variables and joining them with each other.

    You can reference your data source in code simply by its name, for example myDataSource.MyField.

    Also I suggest splitting your task in two.

    1) Add new data source in your form and show value from it on your grid. When this works you know the relations are ok, and you can move to step 2.

    2) Use your new data source in a display method to fetch / show additional data

  • dark_knight Profile Picture
    1,092 on at

    Thank you for the answer. Don't know how to explain this exactly. I also see that my code is simply separate selection of records without any bounding to the form. Let me explain please

    I have added additional datasource called "RouteOpr1". It's connected to "ProdRoute" datasource. Linkype - OuterJoin like that:

    110.JPG

    Then I have added a display method which I wrote above to the table "RouteOpr" and then add it to the grid:

    110.JPG

    The values there have to be retrieved based on the values on the other tab:

    5277.114.JPG

    Still don't have idea how to achieve that. I thought that piece of code below is the relation to my new datasource:

    select * from wrkCtrActivityRequirement
            join wrkCtrActivityRequitementSet
                where wrkCtrActivityRequitementSet.RecId == wrkCtrActivityRequirement.ActivityRequirementSet
            join wrkCtrRouteOprActivity
                where wrkCtrRouteOprActivity.Activity == wrkCtrActivityRequitementSet.Activity
            join routeOpr1
                where routeOpr1.RecId == wrkCtrRouteOprActivity.RouteOpr;

    The last string - where routeOpr1.RecId == wrkCtrRouteOprActivity.RouteOpr I thought is the connection. But seems like not like that. Still don't have idea how to retrieve data from the form or I don;t understand something at all.

    Thank you.

  • Rustem Galiamov Profile Picture
    8,072 on at

    Hi dark_knight!

    A display method require a parameter. You use the parameter to specify a table buffer. The type of the table buffer has to match the type of the table in the form data source.

    Check the link docs.microsoft.com/.../using-the-display-method-modifier

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    Your display method introduces a local variable called RouteOpr1 so it's not using your data source. Although you should see an error that name RouteOpr1  is already used in outer scope.

    Your screenshots are in alphabet that I can't read, could you maybe change your AX language to English to help us understand them?

    The display method should be placed in your form data source. It doesn't need to have a parameter unlike the previous poster suggests. Your display method in form datasource will always have the current active record in the [dataSourceName] variable.

    Did you consider my suggestion about solving the problem one step at a time?

  • dark_knight Profile Picture
    1,092 on at

    Hello guys,

    Thanks but I have created the method on the table because I've read that its better approach to have display methods on the tables rather than on the forms. In that case they are getting reusable in other forms. According to the article if you do so there is no need in modificator in my case:

    A display method for a table, form, report, or report design does not have any parameters. For example:

    display Amount amount()

     

    Rustem,

    Maybe I should add the method to the "RoueOpr1" datasource not tABLE? And now I'm not sure whether I'm doing it correct AT ALL. Maybe I should place the method to some other datasource.?Totally confused. That's how the original task sounds:

    На форме Маршрут (путь к форме: DAX/Управление сведениями о продукте/Обычный/Используемые продукты\Вкладка Инжиниринг на панели действий/Кнопка Маршрут) в нижней части формы добавить поля (расположить после поля Приоритет):

    • ShopNum
    • Производственное подразделение. Д/м (будет использоваться в отчетах). Алгоритм ниже.
    • KMZOPerationCode

     

    Алгоритм заполнения д/м Производственное подразделение:

    1. На вкладке «Потребности ресурса» в сетке, найти первую попавшуюся запись с Тип требования = Группа ресурсов.

    1.1. Если запись найдена, то по найденной записи найти группу ресурсов, указанную в поле Потребность. По найденной группе ресурсов вывести WrkCtrResourceGroup.ProdUnitId

    1.2. Иначе, в той же сетке найти первую попавшуюся запись с Тип потребления = Ресурс

    1.2.1.        Если запись найдена, то

    • по найденной записи найти ресурс, указанный в поле потребность.
    • По найденному ресурсу найти группу ресурсов, в которую он входит на текущую дату: WrkCtrResourceGroupResource.WrkCtrId + Valid
    • По найденной связке найти группу ресурсов WrkCtrResourceGroupResource.ResourceGroup
    • По найденной группе ресурсов вывести WrkCtrResourceGroup.ProdUnitId

    1.2.2.        Иначе поле не заполнять

    I was advised to use "RouteOpr"  table and put my method there but seems like that doesn't works:(

    Thank you again.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    If you add the display method into a table, you must use "this" keyword to refer to the active buffer.

    So instead of introducing new RouteOpr1 variable, use "this".

  • dark_knight Profile Picture
    1,092 on at

    I've rewritten the code with this:

    display ProdUnitId prodUnitId1()
    {
        //RouteOpr                        routeOpr1;
        WrkCtrRouteOprActivity          wrkCtrRouteOprActivity;
        WrkCtrActivityRequirementSet    wrkCtrActivityRequitementSet;
        WrkCtrActivityRequirement       wrkCtrActivityRequirement;
        WrkCtrResourceGroup             wrkCtrResourceGroup;
        WrkCtrResourceGroupResource     wrkCtrResourceGroupResource;
    
    select * from wrkCtrActivityRequirement
            join wrkCtrActivityRequitementSet
                where wrkCtrActivityRequitementSet.RecId == wrkCtrActivityRequirement.ActivityRequirementSet
            join wrkCtrRouteOprActivity
                where wrkCtrRouteOprActivity.Activity == wrkCtrActivityRequitementSet.Activity
            join this
                where this.RecId == wrkCtrRouteOprActivity.RouteOpr;
    
    
    if (wrkCtrActivityRequirement.RelationshipType == WrkCtrActivityRequirementType::ResourceGroup)
        {
            select * from wrkCtrResourceGroup
                where wrkCtrResourceGroup.WrkCtrId == wrkCtrActivityRequirement.requirementEdit();
            return wrkCtrResourceGroup.ProdUnitId;
        }
    
    else if (wrkCtrActivityRequirement.RelationshipType == WrkCtrActivityRequirementType::Resource)
        {
            select * from wrkCtrResourceGroupResource
                where wrkCtrResourceGroupResource.WrkCtrId == wrkCtrActivityRequirement.requirementEdit();
            select * from wrkCtrResourceGroup
                where wrkCtrResourceGroup.RecId == wrkCtrResourceGroupResource.ResourceGroup;
            return wrkCtrResourceGroup.ProdUnitId;
        }
    
        return " ";
    
    }


    but anyway it retrieves the same record all the time with the same recId in this section:

    select * from wrkCtrActivityRequirement
            join wrkCtrActivityRequitementSet
                where wrkCtrActivityRequitementSet.RecId == wrkCtrActivityRequirement.ActivityRequirementSet
            join wrkCtrRouteOprActivity
                where wrkCtrRouteOprActivity.Activity == wrkCtrActivityRequitementSet.Activity
            join this
                where this.RecId == wrkCtrRouteOprActivity.RouteOpr;





    Seems like I use the wrong logic at all and can'e explain what I'd like to achieve:(((
  • dark_knight Profile Picture
    1,092 on at

    Nikolaos Mäenpää,


    I need my method to retrieve values from this tab:

    7752.111.JPG

    Fields on this tab come from the datasource called "WrkCtrActivityRequirement" but my code doesn't apply to this datasource as I get it. How to do this I don't know. My code simply applies to the tables in AOT.

    Thank you.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Could you follow my earlier suggestion (this is the third time I suggest it) and split your problem in two.

    1) Make your display method return only something from the RouteOpr table itself. This way you can make sure your data source relations and other settings are ok.

    2) Then start working on the actual logic in the display method

    Do you think this makes sense?

    If yes, please report your results. You can imagine it's easier to help, and also easier for you (with this task and all future tasks) if you split it into smaller pieces and concentrate on one piece at a time.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    The display method in the table can only see the active record of that table. It can't see anything in your form. If you must use data from other form data sources or controls in your display method, you need to place the display method on the form data source.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans