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 :
Finance | Project Operations, Human Resources, ...
Unanswered

to insert record on click of button on another form

(1) ShareShare
ReportReport
Posted on by 1,836
i have created the insert method on table but i want to insert record on that table on click method of the button i created on form how can i get it done can any one guide me through this .
 
I have the same question (0)
  • Dineshkarlekar Profile Picture
    1,836 on at
    to insert record on click of button on another form
    here is my code for insert method .
       public void insert(NoYes _dropEstimated = NoYes::No)
        {
            InventTable           inventTable;
            InventSum             inventSum;
            InventDim             inventDim;
            DT_Licenseship_dk     dT_Licenseship_dk;
            InventTransferTable   inventTransferTable;
            InventTransferLine    inventTransferLine;
    
            while select * from inventTable
                join inventSum  where inventSum.ItemId  == inventTable.ItemId
                join inventDim  where inventDim.inventDimId == inventSum.InventDimId
                join dT_Licenseship_dk   where dT_Licenseship_dk.LicensePlateId ==  inventDim.LicensePlateId
                join inventTransferTable where inventTransferTable.TransferId == dT_Licenseship_dk.TransferId
                join inventTransferLine  where inventTransferLine.ItemId == inventTable.ItemId
                                               && inventsum.AVAILPHYSICAL > 0
            {
                inventTransferLine.ItemId = inventTable.ItemId;
                inventTransferLine.insert();
            }
    
        }
     
  • André Arnaud de Calavon Profile Picture
    299,947 Super User 2025 Season 2 on at
    to insert record on click of button on another form
    Hi Dinesh,
     
    Is the table where you added the coding the same as the table where you want to insert records? If you want to have an action from a form and insert records in a different table, you can better create put your coding in a class and call the class with help of a menu item button where you can pass the current record to know the relation between the table and the target table for inserting records.
     
    Note that the coding below has no relation with a current record, so it will loop all items that meets the ranges and joins. Is that intended? 
  • Dineshkarlekar Profile Picture
    1,836 on at
    to insert record on click of button on another form
    hi thanks for reply i have created the action menu item and assign the class to the menu item which will be call by my menu item button and the class contain the insert method of the table where i want to insert the values can you please guide me how can i achive the insert on clicked method of munu item button by passing current args , can you share any example on that so i write my code plz
  • Dineshkarlekar Profile Picture
    1,836 on at
    to insert record on click of button on another form
    hi  i am stuck not getting what to do can u plz suggest me any thing on this .
  • Dineshkarlekar Profile Picture
    1,836 on at
    to insert record on click of button on another form
    i have made code on my click button but need to fetch the table 
    below is my code 
     [Control("MenuFunctionButton")]
        class PostButton
        {
            /// <summary>
            ///
            /// </summary>
            public void clicked()
            {     DT_Licenseship_dk        Licenseship;
                InventTable                inventTable;
                InventSum                  inventSum;
                InventDim                  inventDim;
                InventTransferTable        inventTransferTable;
                InventTransferLine         inventTransferLine;
    
    
                  Licenseship = element.args().record(); 
                  Args args = new Args();
    
                str parameterString;
                ;
    
                args.record( Licenseship);
    
                args.parm(Licenseship.LicensePlateId);
     
                //FormDataSource   DT_Licenseship_dk = sender.formRun().dataSource(1);
    
                //args.caller(Licenseship);
    
                Licenseship   = DT_Licenseship_dk_ds.cursor();
    
               select * from inventTable
                join inventSum  where inventSum.ItemId  == inventTable.ItemId
                join inventDim  where inventDim.inventDimId == inventSum.InventDimId
                join dT_Licenseship_dk   where dT_Licenseship_dk.LicensePlateId ==  inventDim.LicensePlateId
                join inventTransferTable where inventTransferTable.TransferId == dT_Licenseship_dk.TransferId
                join inventTransferLine  where inventTransferLine.ItemId == inventTable.ItemId
                    && inventsum.AVAILPHYSICAL > 0;
               
                new MenuFunction(menuItemDisplayStr(DT_LiscencePlateShipMnu_dk), MenuItemType::Action).run(args);
                            
            }
        }
     
  • Martin Dráb Profile Picture
    236,879 Most Valuable Professional on at
    to insert record on click of button on another form
    I'm sorry, but it's not clear to me what table buffer you want to fetch and from where.
     
    By the way, most of your code doesn't do anything. It can be simplified to this:
    [Control("MenuFunctionButton")]
    class PostButton
    {
        public void clicked()
        {
            DT_Licenseship_dk licenseShip = element.args().record(); 
    
            Args args = new Args();
            args.record(licenseShip);
            args.parm(licenseShip.LicensePlateId);
       
            new MenuFunction(menuItemDisplayStr(DT_LiscencePlateShipMnu_dk), MenuItemType::Action).run(args);
        }
    }

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

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

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 588

#3
Martin Dráb Profile Picture

Martin Dráb 542 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans