Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Calling Form with specific record by X++ code

(0) ShareShare
ReportReport
Posted on by 97

Hi All,

I am trying to open a form by giving a specific record but the form opened with all the records.

I debugged the process .The record getting selected, but form not opening with the specified record.

Please guide me on this.

Thanks.

IITProbationEvaluationHeader _iitProbationEvaluationHeader;
MenuFunction mf;
Args args1 = new Args();
Formrun formrun;



_iitProbationEvaluationHeader =IITProbationEvaluationHeader::find("STF-0698");
args1.name(formStr(iiTPerformanceEvaluationAssignToListPage));
args1.record(_iitProbationEvaluationHeader);
formrun = ClassFactory.formRunClass(args1);
formrun.init();
formrun.run();
formrun.wait();

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Calling Form with specific record by X++ code

    Thank you so much Matin.

    Its Working.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 231,407 Most Valuable Professional on at
    RE: Calling Form with specific record by X++ code

    As I said, use this.listPage().listPageArgs() to get the arguments. Then call externalRecord() method to get the record. For example:

    ListPageArgs args = this.listPage().listPageArgs();
    ProbationEvaluationHeader evaluationHeader = args.externalRecord() as ProbationEvaluationHeader;

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Calling Form with specific record by X++ code

    Thanks for the reply Martin,

    8561.MicrosoftTeams_2D00_image.png

    I am calling the menuitem in drillDown method 

    In interaction class,

    pastedimage1669648418452v1.png

    This if condition get satisfied and all records for the particular user eecuted.

    But i need the form should opened with the particular record which i am passing in drilldown method (args.record()).

    So i am thinking if i can pass the recid from the drillDown method and get it in interation class then i can add additional condiotion in IF statement and execute the logic.

    Could you help me how to pass the args.record(table) and get it in interaction class.

    Thanks.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 231,407 Most Valuable Professional on at
    RE: Calling Form with specific record by X++ code

    I see you original didn't tell us a lot of important information.

    Regarding "I tried using args but there is no main method in interaction class", you're wrong in thinking that Args are used only in main() method. Forms don't have main() method either and yet they can receive and use Args. You can call in this.args() to get the object. And in a listpage interaction class, you can use this.listPage().listPageArgs().

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Calling Form with specific record by X++ code

    Thanks Martin and Girish for your reply.

    There are two customized form.

    1.Permance for all users.

    2.Performance assigned for particular user.

    Notification -> Go to Orgin button.

    My task is that when i click on the Go to Orgin, it should open a form ( customized form i.e: performance assigned to the particular user.)

    But now when i click on the Go to orgin it shows all records (performance assigned for all user).

    So i have written code in the EventContextDrillDown class, drill down method,

    Now i can open the form which i need.

    But i need only one record for which the preformance is evaluated.

    I gone through the code in iiTPerformanceEvaluationAssignToListPage (code has been written to show the performs related to the particular user )

    So i am getting all the records fr the particular user .

    Now my question is how to pass value from EventContextDrillDown class and iiTPerformanceEvaluationAssignToListPage (interaction class) .

    1.I tried using args but there is no main method in interaction class.

    2. i created some method in interaction class and try to call the method in EventContextDrillDown .But not able to do . Throwing error."cant create method of listPageInteraction class in non interaction class".

    Could you help me how to pass value from EventContextDrillDown class ->drill down method to iiTPerformanceEvaluationAssignToListPage (list page interaction class) method.

    Thanks.

  • Martin Dráb Profile Picture
    Martin Dráb 231,407 Most Valuable Professional on at
    RE: Calling Form with specific record by X++ code

    As Girish mentioned, it should work automatically if there is a table relation defined.

    But even if it's the case, the form may contain code that breaks the standard logic (either intentionally or by mistake).

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Moderator on at
    RE: Calling Form with specific record by X++ code

    Hi PJ John Paul,

    If you have proper relation it will open automatically against the caller record.

    Other way will be getting the caller record.

    On the called form you need to get the caller record.

    After getting the caller record you need to set the range in the executeQuery method of datasource.

    Refer to the below link for explanation.

    https://dynamics365musings.com/call-a-form-from-another-form/

    Thanks,

    Girish S.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans