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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Pass value from custom list page to custom user control in EP

(0) ShareShare
ReportReport
Posted on by 360

Hi,

We have a custom list page that has been deployed to the EP. On the action pane we have a menu item button that has a WebMenuItemName that links to a custom user control.

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

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Iulian Cordobin Profile Picture
    8,201 on at

    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;

       }

    The option of sending the RecId directly in the QueryString would be possible if you would not be calling your web control from a list page, but from a standard form where you would be able to actually append ExtraParams to the QueryString.

  • Iulian Cordobin Profile Picture
    8,201 on at

    Also, you can do it without declaring an AxDataSource in your web control, instead get the data using the WKey param with:

              if (this.AxQueryString != null && this.AxQueryString.RecordContext != null)

               {

                   IEnumerator<KeyValuePair<int, object>> en = this.AxQueryString.RecordContext.DataKey.GetEnumerator();

                   int fieldId = this.AxQueryString.RecordContext.DataKey.Table.Fields.GetByName("RecId").FieldId;

                   while (en.MoveNext())

                   {

                       if (en.Current.Key == fieldId)

                       {

                           Int64 recId = Convert.ToInt64(en.Current.Value);

                           break;

                       }

                   }

               }

    and declaring before

       private AxQueryString AxQueryString

       {

           get

           {

               return AxQueryString.GetCurrent(this.Page);

           }

       }

  • robertk Profile Picture
    360 on at

    Thanks. For some reason I always just get the first record in the table. Not the record selected from the list page.

    I'm always seem to be missing the link between the list page and the user control through the action pane.

    I have set the Needs record and send external context and data source.

  • robertk Profile Picture
    360 on at

    It works fine getting the WKEY if I specify the hyperlink on the grid.

    Then I can use:

    KeyValuePair<int, string> kvRecId = ControlHelper.DecryptWKEY(AxQueryString.GetCurrent(Page));

    To get the RecId and it works. But I want to be able to use the action pane.

  • robertk Profile Picture
    360 on at

    I see you have samples taken from the Enterprise Cookbook. But I haven't figured out how to implement the DataSourceView method, any tips?

    I just have the AxDataSource added to the user control for a DataSet containing only the table from the ListPage.

  • Verified answer
    robertk Profile Picture
    360 on at

    Turns out it wasn't problem with my code. I created a new menu item button with target only on EP, linked to new menu item that was only linked to web menu item. Then everything started to work.

    The existing menu item had a form specified for it (that should only open in AX), maybe that was causing the issue of the record not being passed to the user control.

  • Community Member Profile Picture
    on at

    Hi, can anyone paste a sample code to run a class off action menu item in EP that would read record/datasource from caller EP list page. The objective is to run an action (class) from List Page in EP that would update certain recods and refresh list page data set. Appreciate your help

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans