Skip to main content

Notifications

Announcements

No record found.

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
    Ajit Profile Picture
    Ajit 8,755 on at
    RE: Customization on EP

    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.

  • Verified answer
    RE: Customization on EP

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans