Monday, December 7, 2015

AX 2012: Get Current record in EP

    How do I pass the RecId of the selected record in the list page     to the user control?


Setting the proper properties on the menu item in the list page form will pass the record to the              web user control.
On the menu item just set the NeedsRecord to Yes (not mandatory, but better to have it set in               order for the button to be disabled/enabled), and the DataSource property to the table you want           to have its record passed.

In your user control just add an AxDataSource for a DataSet having the same table, and you will         get your record.

Then just get the record using a standard call in EP as shown (you must also have the                           DataSourceView method implemented):

internal IAxaptaRecordAdapter GetCurrentDatasourceRecord()

{

       IAxaptaRecordAdapter record = null;

       if (this.DataSourceView.DataSetView != null &&

           this.DataSourceView.DataSetView.GetCurrent() != null)

       {

           //setting the record as the current record in the datasource

           record = this.DataSourceView.DataSetView.GetCurrent().GetRecord();

       }

       return record;

   }

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8