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

Open a Dialog Form from a parent form button and show only the selected records

(0) ShareShare
ReportReport
Posted on by 685

hi, please find below my situation:
On the create Purchase Order button of "Release Approved purchase requisition" form, i need to open a new dialog form "MS_PrFillContractNumber"to let the user fill a new customized field "contract number" for the selected records in the current form.
The menu item of the Create PO button refers to a class named "RequisitionReleaseStrategy"; so in the run() function of this class i insert this line "this.FillContract();" FillContract() is a new function containing the below code;

private void FillContract()
{
FormRun formRun;
Args args = new Args();
args.name(formStr(MS_PrFillContractNumber));
args.caller(this);

formRun = classfactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();

//new MenuFunction(menuitemDisplayStr(MS_PrFillContractNumber),MenuItemType::Display).run(args);
}
the datasource of new form "MS_PrFillContractNumber" is the PurchReqLine table, i have added a new grid in the design containg 3 columns (PurchReqlineID, item Number, contract number); and below is the code of init() function:

caller = element.args().caller();
if (!caller)
{
throw error(strfmt("@SYS22678",element.name()));
}

super();

i have tried several codes in the init function; the problem is that the new form is always showing all the records.
can anyone give me a detailed solution to show only the selected records in the parent form.

you help is very appreciated



*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

    Create temp table to insert the selected records. and get the selected records by using the following code..

    Temptable tmptable;

    parentFormTable tableData;

    tableData = parentFormTable_ds.getfirst(true)

    while(tableData )

       {

                   tableData = parentFormTable_ds.getNext();

                   tmptable.YourField = tableData.ParentField;

                   tmptable.insert();

       }

    use query in your second form and join this temp table. you can get the selected records :)

    Thanks,

    Selvam

  • Serge Abi Dib Profile Picture
    685 on at

    thanks Selvam, but i need to do that using args without create temp table

  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

    You can use the following:

    FormDataSource      fds = _args.record().dataSource();

    for (myTable = fds.getFirst(1) ? fds.getFirst(1) : _args.record(); myTable; myTable = fds.getNext())

    {

       //Make use of your record here.

      myTable...

    }

  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi S.AD does this resolve your query or can we assist you further?

  • Serge Abi Dib Profile Picture
    685 on at

    Hi Jon, well the menu item of the Create PO button in the "Release approved purchase requisitions" form is calling a class "RequisitionReleaseStrategy" , i think the code you gave me is functional when the menu item call a form;

    Anyway what i wanted is to oblige the user to fill the "Contract Number" customized field when creating the PO...i went through the debugger and i found that on the same button the system oblige the user to put the vendor in case no vendor account is specified on the PR level (class\RequisitionPurchaseOrderGeneration getVendor function), so i did the same by creating a MAP and modifyin the code in getvendors , setselectedvendors, create methods and i added the contract number to the vendor form (PurchReqAddVendor)....

    I don't know if i was clear. thanks jonathan for your follow up

  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi S.AD

    The code supplied will work on a called form or class, it just needs an args object passed.

    But it seems like you have resolved your issue. Maybe just mark your own post as the answer to the thread.

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

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans