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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Form problem - how to display User name of Created by

(0) ShareShare
ReportReport
Posted on by 506

I want to display the Created by user but instead of the user id I want to display the user name.

I want the column to be filter-able and so do not want to use display method but to rely on the form datasource.

The form is the Item requirements form, ProjSalesItemReq.

Item-req-form-with-column.PNG

ItemReq-Form.PNG

In the AOT, I've added the datasources, DirPersonUser and DirPartyTable and dynamically linked them to the form datasource using their init() methods, as follows:

public void init()
{
    #DEFINE.DataSourceDirPerson('DirPersonUser')

    QueryBuildDataSource qbds;

    super();

    qbds = this.query().dataSourceName(#DataSourceDirPerson);
    qbds.clearLinks();
    qbds.addLink(fieldNum(SalesLine,CreatedBy),fieldNum(DirPersonUser,User));
}

public void init()
{
    #DEFINE.DataSourceDirPartyTable('DirPartyTable')

    QueryBuildDataSource qbds;

    super();

    qbds = this.query().dataSourceName(#DataSourceDirPartyTable);
    qbds.clearLinks();
    qbds.addLink(fieldNum(DirPersonUser,PersonParty),fieldNum(DirPartyTable,RecId));
}

However, when I create an Item requirement by clicking on the New button I get this dialog "Select a record type to create":

Item-req-dialog.PNG

There must be some way to prevent this from happening but allow the User name column to be displayed and filterable?

For info, I have set the new datasources as follows:

DirPartyTable-datasource.PNG

DirPersonUser-datasource.PNG

I have tried setting the JoinSources to Passive and Delayed but then the form does not load and I get errors saying these are not part of the parent datasource.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    _MGP Profile Picture
    506 on at
    RE: Form problem - how to display User name of Created by

    I've managed to solve this one partially.

    This forum post has a closing comment which sent on me the right track.

    I created a new view UserNames, joining the 2 tables DirPersonUser and DirPartyTable exposing the Name and User fields. Then added this as a form datasource joining to SalesLine as an inner join and overrode the init() method of the view's datasource as follows:-

    public void init()
    {
        #DEFINE.DataSourceUserNames('UserNames')
    
        QueryBuildDataSource qbds;
    
        super();
    
        qbds = this.query().dataSourceName(#DataSourceUserNames);
        qbds.clearLinks();
        qbds.addLink(fieldNum(SalesLine,CreatedBy),fieldNum(UserNames,User));
    }


    However, I cannot seem to programatically refresh the form after a new record is saved so that the new user's name is automatically displayed.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans