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

Data in the Dialog Form

(0) ShareShare
ReportReport
Posted on by 390

Hey Team,

I'm working with the dialog form for the first time and I have a parent form whose action pane consists of a button (action menu item) which when clicked opens a dialog form to change the field "End Date". Now this dialog form consists of field like "Personnel Number, FirstName, LastName" which are not editable and these values should come from the parent form, but in my case when I select a record from the parent form and click action menu item the dialog forms shows the values for "FirstName, LastName"  from the data source table(first record in the table) and not the selected record also Personnel Number value is not visible. How can I solve this issue? I want the dialog form to have information of the selected record from the parent form.

ChangeEndDateForm.png

I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    You can get the selected record from the parent form by calling this.args().record() in the dialog form (e.g. in init() method). Then you must somehow use data from it in your dialog fields.

    One option is using unbound fields populated from code. Another is using a data source and adding a filter (e.g. for RecId) based on the record you receive.

  • skd Profile Picture
    390 on at

    Hey Martin Dráb ,

    Could you please elaborate how to use this.args().record() .

    I wrote it in the init() method of dialog form but couldn't get the desired output. Can you please tell me where I'm going wrong?

      public void init()
        {
            super();
            this.args().record();
        }

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    record() gives you the data, but you completely ignore the return value, therefore the call has no effect.

    Before writing any code, you must decide what you want it to do. I mentioned two possible ways above - choose one of them. (There are more possible solutions, but let's keep it simple).

  • skd Profile Picture
    390 on at

    Hey Martin Dráb,

    Can we go with this way: " using a data source and adding a filter (e.g. for RecId) based on the record you receive"? If yes, pls help me, how can I go ahead with this approach?

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    How are you opening the dialog form? Are you using a menu item button? Is the the same table or are those two different tables?

    I'm asking because you should normally get a dynamic link that that do the filtering automatically.

    If we get this working, you won't have to write any code at all.

  • skd Profile Picture
    390 on at

    YEs I'm using the action menu item. The dialog form has two tables both of the parent form table datasource.

  • skd Profile Picture
    390 on at

    I tried to take some reference from the standard forms available and tried this and it worked. Is this right the way I have done it?

    public void setHcmWorker(HcmWorkerRecId _WorkerRecId)
        {
            QueryBuildRange qbr;
    
            mytable_ds.query().clearQueryFilters();
            mytable_ds.query().dataSourceTable(tableNum(mytable)).clearRanges();       
            qbr = mytable_ds.query().dataSourceTable(tableNum(mytable)).addRange(fieldNum(mytable, RecId));
            qbr.value(int642str(_WorkerRecId));       
            mytable_ds.executeQuery();
        }
    
        public void init()
        {
           
            super();
            if (element.args()
                && element.args().record()
                && element.args().record().TableId == tableNum(mytable))
            {
                element.setHcmWorker(element.args().record().RecId);
            }
            
        }

  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Yes, it's a possible way (if you don't want a dynamic link), although your code is over-complicated. Also, calling executeQuery() from init() is wrong. I would change the method to this:

    public void setFilter(RecId _myTableRecId)
    {
    	QueryBuildRange recIdRange = myTable_ds.queryBuildDataSource().addRange(fieldNum(MyTable, RecId));
    	recIdRange.value(queryValue(_myTableRecId));
    }

  • skd Profile Picture
    390 on at

    Hey Martin Dráb,

    Thank you so much.

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 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans