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
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,228 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156