How to Passing Args(single record) from one Form to another Form in dynamics D365 using X++ code

 Step 1: Make one SampleTable which has three fields named (SIno, name, AddressCity).

Step 2: Make FormA with datasource as SampleTable and drag the datasource fields into the design Grid.
Step 3: Drag one button and override the click method and write the following code.

code:


     [ExtensionOf(formStr(CustTable))]
final class BASCustDetails_Extension
{
    
    public void clicked()
    {
        Args args;
        FormRun formRun;
        ;
        //super();
        args = new args(formstr(BASCustForm)); // sending Args(record) to FormB
        args.record(CustTable);
        formrun = classfactory.formrunclass(args);
        formrun.init();
        formrun.run();
        formrun.wait();
        formrun.detach();
           
    
    }

}


step 4: Make FormB with datasource as same table for which you take for Form A i.e., SampleTable and drag the fields in to the
Grid of design part.
step 5: write the following code in to the init method of FormB.


[Form]
public class BASCustForm extends FormRun
{


    [DataSource]
    class BASCustTable
    {
        /// <summary>
        ///
        /// </summary>
        public void init()
        {
            BASCustTable bascust;
            CustCustomerV3Entity custcustomer;
            CustTable _sampleTable=element.args().record();;
            super();

            delete_from bascust;

            select * from custcustomer where custcustomer.CustomerAccount==_sampleTable.AccountNum;
             
            bascust.PrimaryMobileNumber=custcustomer.PrimaryContactPhone;
            bascust.PrimaryAddress=custcustomer.FullPrimaryAddress;
            bascust.insert();

           
        }

    }

}

Comments

Popular posts from this blog

How to Create a wizard in x++ d365

how to post trade agreement journals automatically using x++ code

X++ code to CREATE AND POST A TRADE AGREEMENT IN MICROSOFT DYNAMICS 365 in D365 F & O