Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

to insert record on click of button on another form

(1) ShareShare
ReportReport
Posted on by 1,479
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 .
 
  • Martin Dráb Profile Picture
    Martin Dráb 230,848 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);
        }
    }
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 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);
                            
            }
        }
     
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 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
    Dineshkarlekar 1,479 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
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,979 Super User 2025 Season 1 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
    Dineshkarlekar 1,479 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();
            }
    
        }
     

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans