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 :
Microsoft Dynamics AX (Archived)

Customization on EP

(1) ShareShare
ReportReport
Posted on by 660

Hi Friends,

We want to add a lookup of the vendor master when we create the expense report in EP. Can we do that?

*This post is locked for comments

  • Verified answer
    Rodolfo Recalde Profile Picture
    on at

    Hi,

    Well, there are some ways you can achieve this goal, by create  a custom lookup in user control, or by create/ change the lookup in AX.

    If the lookup only changes the report, in some cases, you only need to change the report configuration or class.

    Take a look in page 28, 57, 67 ,132 for some examples and explanations: 

    Microsoft Dynamics AX 2012 White Paper: Enterprise Portal Development Cookbook

    If you need more help, please, explain more your problem, with more detail.

    I Hope this Helps!

    Regards,

    Rodolfo Recalde.

  • Verified answer
    Ajit Profile Picture
    8,788 on at

    Yes, you can write a lookup method on web control, something like below -

    Note - This is NOT for vendor drop down.

     protected void Account_Lookup(object sender, AxLookupEventArgs e)
        {
            AxLookup lookup = e.LookupControl;

            // Create the lookup dataset - we will do a lookup in the Contact person table
            using (BCProxy.SysDataSetBuilder sysDataSetBuilder = BCProxy.SysDataSetBuilder.constructLookupDataSet(
                this.AxSession.AxaptaAdapter, TableMetadata.TableNum(this.AxSession, "VendBankAccount")))
            {
                // Set the run time generated data set as the lookup data set
                lookup.LookupDataSet = new Microsoft.Dynamics.AX.Framework.Portal.Data.DataSet(this.AxSession, sysDataSetBuilder.toDataSet());
            }

            BCProxy.Query query = lookup.LookupDataSet.DataSetViews[0].MasterDataSource.query();
            query.allowCrossCompany = true;
            query.addCompanyRange(GetCompanyLine());
            using (BCProxy.QueryBuildDataSource qbds = query.dataSourceNo(1))
            {
                using (BCProxy.QueryBuildRange range = qbds.addRange(TableDataFieldMetadata.FieldNum("VendBankAccount", "VendAccount")))
                {
                    DataSetViewRow PaymentLine = this.dsEPPaymentEdit.GetDataSourceView("PaymentLine").DataSetView.GetCurrent();
                    if (PaymentLine != null)
                    {
                        using (IAxaptaRecordAdapter record = asuPaymentLine.GetRecord())
                        {
                            if (record != null)
                            {
                               
                                AppProxy.VendTable vendTable = AppProxy.VendTable.findByCompany((string)record.GetField("Company"),(string)record.GetField("Account"));
                                // Filter the lookup
                                range.value = Convert.ToString(vendTable.AccountNum);
                                range.status = (int)BCProxy.RangeStatus.Hidden;
                            }
                        }
                                

                    }
                }
               
            }
            
            lookup.LookupDataSet.Init();

            // Specify the lookup fields used
            lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.LookupDataSetViewMetadata.ViewFields["AccountId"]));
            lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.LookupDataSetViewMetadata.ViewFields["Name"]));
            lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.LookupDataSetViewMetadata.ViewFields["AccountNum"]));

            // Specify the select field
            lookup.SelectField = "AccountId";
        }

        #endregion

    Call it as below -

    <dynamics:AxBoundField DataField="Account" DataSet="EPPaymentTableEdit" DataSetView="PaymentLine" SortExpression="Account" AutoPostBack="true"
                                OnDataChanged="Account_DataChanged" LookupButtonDisplaySettings="Always" OnLookup="Account_Lookup">
                            </dynamics:AxBoundField>

    You can override dataSetLookup on dataset as well.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans