web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

how can i passing formdatasource to a class?

(0) ShareShare
ReportReport
Posted on by

hi all!
how can I pass a form DataSource to a class because it gives me an error of the tablename_ds is not declared?

[FormControlEventHandler(formControlStr(RetailTransactionTable, RetailReport_Transaction), FormControlEventType::Clicked)]
    public static void RetailReport_Transaction_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        MultiSelectionHelper                    selectionHelper = MultiSelectionHelper::construct();
         
        RetailTransactionTable                  retailTransactionTable;
       
        str                                     transId;
            
      
        selectionHelper.parmDataSource(TableName_ds);
        retailTransactionTable1  = selectionHelper.getFirst();

        transId = retailTransactionTable.transactionId;
        }

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, You need to initialize FormDatasource buffer. Try adding below code at Line#9

    FormDatasource TableName_ds = sender.formrun().datasource(IdentifierStr(Tablename));

    Replace TableName with name of Datasource name.

  • Suggested answer
    GirishS Profile Picture
    27,833 Moderator on at

    If you are writing COC then you can use directly the variables and DataSource names - If you are using event handlers you need to get form run and then get the datasource from form run.

    [FormControlEventHandler(formControlStr(RetailTransactionTable, RetailReport_Transaction), FormControlEventType::Clicked)]
        public static void RetailReport_Transaction_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            MultiSelectionHelper                    selectionHelper = MultiSelectionHelper::construct();
             
            RetailTransactionTable                  retailTransactionTable;
           
            str                                     transId;
                
            //get the form run
            FormRun frun = sender.formRun();
            FormDataSource fds = frun.datasource(formDataSourceStr(FormName,DataSourceName));
            selectionHelper.parmDataSource(fds);
            retailTransactionTable1  = selectionHelper.getFirst();
            if(retailTransactionTable1)
            {
                //do some process
                transId = retailTransactionTable.transactionId;
                retailTransactionTable1 = selectionHelper.getNext()
            }
                
            }

    Thanks,

    Girish S.

  • 365 financial Profile Picture
    on at

    hi when i try your line i recieved this error when trying to run the form

  • GirishS Profile Picture
    27,833 Moderator on at

    Have you debugged the code?

    Find out in which line the error is throwing.

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 386

#3
Adis Profile Picture

Adis 259 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans